Question: Assume I have a set of weighted samples, where each samples has a corresponding weight between 0 and 1. I'd like to estimate the parameters of a gaussian mixture distribution that is biased towards the samples with higher weight. In the usual non-weighted case gaussian mixture estimation is done via the EM algorithm.

Is there an implementation (any language is OK) that permits passing weights? If not, how can I modify the algorithm to account for the weights? If not, how to incorporate the weights in the initial formula of the maximum-log-likelihood formulation of the problem?

Answer: 
You can calculate a weighted log-Likelihood function; just multiply the every point with it's weight. Note that you need to use the log-Likelihood function for this.

So your problem reduces to minimizing $-\ln L = \sum\_i w\_i \ln f(x\_i|q)$ (see [the Wikipedia article](http://en.wikipedia.org/wiki/Maximum_likelihood#Principles) for the original form).
I think this analysis can be possibly be done via the `pomegranate` (see [Pomegranate](https://pomegranate.readthedocs.io/en/latest/) docs page) that supports a weighted Gaussian Mixture Modeling.

According to their doc:

> 
> weights : array-like, shape (n\_samples,), optional
> The initial weights of each sample in the matrix. If nothing is
> passed in then each sample is assumed to be the same weight.
> Default is None.
> 
> 
> 

Here is a Python snippet I wrote that can possibly help you do a weighted GMM:

```python
from pomegranate import *
import numpy as np

# Generate some data
N = 200
X_vals= np.random.normal(-17, 0.9, N).reshape(-1,1) # Needs to be in Nx1 shape
X_weights = w_function(X_vals) # Needs to be in 1xN shape or alternatively just feed in the weight data you have

pmg_model = GeneralMixtureModel.from_samples([NormalDistribution], 2, X_vals, weights=X_weights.T[0])

```

[[Figure] Observed versus weighted distribution of the data we are analyzing](https://i.stack.imgur.com/xL87i.png)

[[Figure] GMM of the weighted data](https://i.stack.imgur.com/2hMdf.png)