Mixture Distribution Using Python

426 views Asked by At

Really need help with this question. I may be overthinking. Any help will be appreciated! Thank you!

Let X ∼ N(0, 1) and Y ∼ N(4, 2).

(a) Plot the distribution of the mixture distribution where X is selected with probability p and Y with probability (1−p) for three different values of p

So I got started, but not sure if I am on the right path...still trying different things

import numpy as np
import numpy.random
import scipy.stats as ss
import matplotlib.pyplot as plt


n = 10000
numpy.random.seed(0x5eed)
# Parameters of the mixture components
norm_params = np.array([[5, 1],
                        [1, 1.3],
                        [9, 1.3]])
n_components = norm_params.shape[0]
1

There are 1 answers

1
Igor Rivin On

To plot the distribution, just sample a lot of times from the mixture (in the obvious way), then plot the histogram of the samples. Mean and variance are moments, so linear combinations of the corresponding quantities for the two components. (c) and (d) are experimental, so just do the experiment.