I am trying to generate 100 samples from 2 different Gaussian distributions, such that G1 occurs with probability 0.7 and G2 occurs with 0.3. I have the following code snippet:
from scipy.stats import norm
import numpy as np
x = [norm.rvs(0, 1, size=5), norm.rvs(10, 1, 5)]
draw = np.random.choice([0, 1], 100, p=[0.7, 0.3])
y = [x[i].rvs() for i in draw]
z = np.array(y)
When I compile this, I get the following error:
AttributeError: 'numpy.ndarray' object has no attribute 'rvs'
Is there something I am missing? Or, is there a fundamental flaw?