Учитывая двух разных гауссиан, как я могу создать смесь двух гауссианов, где каждая точка данных - от первого гауссиана с вероятностью p = 0,3 и от второго с вероятностью 0,7 (используя распределение Бернулли для вероятностей).
Вот мой старт:
import numpy as np
mu1, sigma1 = 1, 2 # mean and standard deviation
g1 = np.random.normal(mu1, sigma1, 1000)
mu2, sigma2 = 4, 8 # mean and standard deviation 2
g2 = np.random.normal(mu2, sigma2, 1000)
p = .3 # probability
b = np.random.binomial(1, p, 1000)
# How to combine these to sample from mixture?
# Combining gaussians would be:
combined_gaussians = np.random.normal(mu1+mu2, np.sqrt(sigma1^2 + sigma2^2))
# In this case, can we just do a linear combination of the samples?:
combined_samples = b*g1+(1-b)g2