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

[BUG] Weighting in GMM is ignored #1098

Open
david-schl opened this issue May 7, 2024 · 0 comments
Open

[BUG] Weighting in GMM is ignored #1098

david-schl opened this issue May 7, 2024 · 0 comments

Comments

@david-schl
Copy link

david-schl commented May 7, 2024

Describe the bug
Given two events E1 and E2 with a certain probability of occurrence. Each event leads to certain values according to a normal distribution. To calculate the overall probability for the values, also considering the probability of occurrence of the events, I want to use the GeneralMixtureModel.

The normal distributions are the input values for the GeneralMixtureModel(), which leads to a mixed probability distribution. But as the probability of occurrence varies, they are used as weights. The problem is that the weights seem to have no influence on the result at all. Varying E1_prob and/or E2_prob does not change the result.

To Reproduce

from pomegranate.distributions import *
from pomegranate.gmm import GeneralMixtureModel
import numpy as np
import matplotlib.pyplot as plt

# Probability of occurrence of events
E1_prob = 9.79E-1
E2_prob = 1-9.79E-1

# Values in case the event occurs
E1_values = Normal([1000.0], [[200.0**2]])
E2_values = Normal([2000.0], [[400.0**2]])

# Overall probability for values
Values_overall = GeneralMixtureModel([E1_values,E2_values])
Values_overall.weights = [E1_prob,E2_prob]

x = np.linspace(-200, 4000, 1000).reshape(-1, 1)  # Reshape x to be a 2D array

pdf = Values_overall.probability(x)

# Plot the PDF
plt.figure(figsize=(10, 6))
plt.plot(x, pdf, label='Normal Distribution')
plt.xlabel('x')
plt.ylabel('Probability Density')
plt.legend()
plt.grid(True)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant