Given two different gaussians, how can I create a mixture of the two gaussians where each datapoint is from first gaussian with probability p = 0.3 and from second with probability 0.7 (using a bernoulli distribution for the probabilites).
Here is my start:
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