jax version of GeneralizedExtremeValue distribution has wrong support for concentration=0

Đang mở
#1,839 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
machine-learning

Hướng nghiên cứu

Bắt đầu với tfd.GeneralizedExtremeValue trong tensorflow_probability.substrates.jax.distributions và chạy bản tái hiện JAX được cung cấp cho các giá trị concentration xung quanh 0. So sánh hành vi support và log_prob được báo cáo tại concentration=0 với support không bị chặn được mong đợi; issue được hoàn tất khi JAX substrate xử lý trường hợp đó nhất quán với kỳ vọng đã nêu và hành vi liên quan được bao phủ bởi một regression test.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

It seems like the support of the GEV is (-1.0, inf) for concentration=0, rather than the expected (-inf, inf). I am using:

  • tensorflow-probability 0.24.0
  • jax 0.4.30

I only tested this for the tensorflow_probability.substrates.jax.distributions version.

Otherwise, the support seems to be fine. Here's a little experiment for reproducing my findings:

import tensorflow_probability.substrates.jax.distributions as tfd
import jax.numpy as jnp
import pandas as pd
from itertools import product

def nominal_gev_support(loc, scale, concentration):
    if jnp.allclose(concentration, 0.0):
        return (-jnp.inf, jnp.inf)
    
    if concentration > 0.0:
        return (loc - scale / concentration, jnp.inf)
    
    if concentration < 0.0:
        return (-jnp.inf, loc - scale / concentration)

x = jnp.linspace(-5, 5, 1000)
cases = []

locs = [0.0]
scales = [1.0]
concentrations = list(jnp.linspace(-2, 2, 9))

for loc, scale, concentration in product(locs, scales, concentrations):
    cases.append({"loc": loc, "scale": scale, "concentration": concentration})


dfs = []
for case in cases:
    gev = tfd.GeneralizedExtremeValue(
        loc=case["loc"], scale=case["scale"], concentration=case["concentration"]
    )

    lp = gev.log_prob(x)
    not_nan_indices = jnp.argwhere(~jnp.isinf(lp))

    nominal_min, nominal_max = nominal_gev_support(
        loc=case["loc"], scale=case["scale"], concentration=case["concentration"]
    )

    data = {
        "nominal_min": nominal_min,
        "nominal_max": nominal_max,
        "observed_min": x[not_nan_indices].min(),
        "observed_max": x[not_nan_indices].max()
    }
    
    data |= case

    df = pd.DataFrame(data, index=[0])
    dfs.append(df)

results = pd.concat(dfs)

results

Bildschirmfoto 2024-09-20 um 12 04 15

Ngôn ngữ chính
Jupyter Notebook
Star
4.4k
Fork
1.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tensorflow/probability

Tất cả issue của tensorflow/probability

Issue tương tự

Thêm issue về Machine Learning

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.