title: EM algorithm python on MNIST image data
body: <p>I need to implement the EM algorithm for fitting a GMM on image data (pixels). The data was provided as a .mat file. The data is similar to the MNIST dataset. So it's a matrix of images with the shape 784 x 1990. There are 1990 images, and each column of the matrix corresponds to one image of size  28 x 28 pixels (so 28*28 = 784).</p>
  
  <p>I see alot of examples online for EM in python, but none for working with images. Most generate data like below. How should I work with these image vectors of pixels? I'm unsure how to reshape it or how to begin this task. Do I average the pixels of each column? What should my target X be- a list or a list of lists? In my humble opinion, I think I need to get x,y coordinates of each black and white image.</p>
  
  <pre><code>random_seed=36788765
  np.random.seed(random_seed)
  
  Mean1 = 2.0  # Input parameter, mean of first normal probability distribution
  Standard_dev1 = 4.0 #@param {type:"number"}
  Mean2 = 9.0 # Input parameter, mean of second normal  probability distribution
  Standard_dev2 = 2.0 #@param {type:"number"}
  
  # generate data
  y1 = np.random.normal(Mean1, Standard_dev1, 1000)
  y2 = np.random.normal(Mean2, Standard_dev2, 500)
  data=np.append(y1,y2)
  </code></pre>
  
  <p>Or like this, where there is an X and Y to generate a scatter plot:</p>
  
  <pre><code>from sklearn.datasets.samples_generator import make_blobs
  
  # Create dataset
  X,Y = make_blobs(cluster_std=1.5,random_state=20,n_samples=500,centers=3)```
  
  </code></pre>