Here is a simplified implementation to demonstrate this implementation:

```python
import numpy as np

X = np.random.sample(100)
w = np.random.sample(100)

def cov(X, w):
    X = np.array(X, ndmin=2, dtype=float)
    X -= np.average(X, axis=1, weights=w)[slice(None), np.newaxis]
    w_sum = w.sum()
    return (np.dot(w * X, X.T.conj()) /
        (w_sum - np.power(w, 2).sum() / w_sum)).squeeze()

print cov(X, w)
print cov(X, w * 5)
print cov(X, np.ones(100))
print np.cov(X)
```