0
$\begingroup$

I have times series of wind direction and velocity. For now, I leave aside the velocity and focus on the distribution of wind directions.

Over there, there is usually three main wind directions, and variations around these directions.

My goal is to quantify these directions as well as the proportion of time associated to each main directions. My first guess was to trying to fit this with Gaussian mixture model:

import numpy as np
import matplotlib.pyplot as plt
from sklearn.mixture import GaussianMixture

data = np.loadtxt('file.txt') ##loading univariate data.

gmm = GaussianMixture(n_components = 3).fit(data.reshape(-1, 1))

plt.figure()
plt.hist(data, bins=50, histtype='stepfilled', density=True, alpha=0.5)
plt.xlim(0, 360)
f_axis = data.copy().ravel()
f_axis.sort()
a = []
for weight, mean, covar in zip(gmm.weights_, gmm.means_, gmm.covariances_):
    a.append(weight*norm.pdf(f_axis, mean, np.sqrt(covar)).ravel())
    plt.plot(f_axis, a[-1])
plt.plot(f_axis, np.array(a).sum(axis =0), 'k-')
plt.xlabel('Variable')
plt.ylabel('PDF')
plt.tight_layout()
plt.show()

enter image description here

The fit is not that good, and we guessed it is because there is also a 'background noise' of uniformly distributed data. In another word, everything below y = 0.17 (or something around this) should not exist.

Is there anyway to take this into account ?

How to fit a mixture of gaussian and uniform distributions ?

Note that these are angular data (periodic), but I did not take this into account. As a result, the half peak around 360 is part of the first main peak at 50.

$\endgroup$
4
  • 2
    $\begingroup$ Because the range of your variable is $[0,360]$ I would guess you have an angle -- a kind of circular variable. That requires special treatment , especially in this case. Instead of asking for an abstract solution to an abstract problem that might not give you a good answer (or even a correct one), why not disclose the actual problem you are trying to solve? $\endgroup$ – whuber Dec 3 '20 at 12:18
  • $\begingroup$ How do you know there are three peaks? It seems that the histogram has three peaks with a "half-peak" at the right tail. I am wonder whether it sounds something? $\endgroup$ – TrungDung Dec 3 '20 at 12:29
  • $\begingroup$ Thanks for these comments ! I'll edit my question based on it. $\endgroup$ – Liris Dec 3 '20 at 12:56
  • $\begingroup$ I don't see much of a benefit from fitting a Gaussian mixture model, in part because the peaks are not Gaussian (they are too sharp and one of them is too skewed): this enterprise is doomed. But you can readily achieve your objective of estimating the principal directions and proportions of time: the peaks are clearly identifiable--this needs no statistical procedure to achieve--so all that's left is to estimate the boundaries between them. You could use the bottoms of the valleys that separate them, for instance; but the best way will depend on your loss function. $\endgroup$ – whuber Dec 4 '20 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.