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()
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.