Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RV: Samples do not know of RV name #615

Open
nabriis opened this issue Jan 27, 2025 · 0 comments
Open

RV: Samples do not know of RV name #615

nabriis opened this issue Jan 27, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@nabriis
Copy link
Collaborator

nabriis commented Jan 27, 2025

Description

The samples object does not include (or at least the histogram plot does not) the variable name of the random variable

Example to reproduce

Provide a code example to reproduce the bug

from cuqi.distribution import Beta, Gamma

# Define the shape parameters of the Beta distribution
a1, a2 = 3, 2

# Step 1: Directly define a Beta distribution
z_ref = RandomVariable(Beta(a1, a2))

# Step 2: Construct the Beta distribution using Gamma random variables
x = RandomVariable(Gamma(a1, 1))  # X ~ Gamma(a1, 1)
y = RandomVariable(Gamma(a2, 1))  # Y ~ Gamma(a2, 1)
z = x / (x + y)                   # Z ~ Beta(a1, a2)

# Step 3: Sample from both distributions
z_samples = z.sample(10000)       # Samples from constructed Beta distribution
z_ref_samples = z_ref.sample(10000)  # Samples from direct Beta distribution

# Step 4: Plot histograms of the samples for comparison
z_samples.hist_chain([0], bins=100)
z_ref_samples.hist_chain([0], bins=100)
@nabriis nabriis added the bug Something isn't working label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant