I have a histogram of wind speed data which is often represented using a weibull distribution. I would like to calculate the weibull shape and scale factors which give the best fit to the histogram.

I need a numerical solution (as opposed to graphic solutions) because the goal is to determine the weibull form programmatically.

Edit: Samples are collected every 10 minutes, the wind speed is averaged over the 10 minutes. Samples also include the maximum and minimum wind speed recorded during each interval which are ignored at present but I would like to incorporate later. Bin width is 0.5 m/s

Histogram for 1 month of data

  • 1
    $\begingroup$ when you say you have the histogram - do you mean also have the information about the observations or do you ONLY know the bin width and height? $\endgroup$ – suncoolsu Mar 30 '11 at 11:10
  • $\begingroup$ @suncoolsu I have all data points. Datasets ranging from 5,000 to 50,000 records. $\endgroup$ – klonq Mar 30 '11 at 11:12
  • $\begingroup$ Couldn't you take a random sample of the data and perform a MLE of the parameters? $\endgroup$ – schenectady Mar 30 '11 at 11:30
  • 2
    $\begingroup$ What's the purpose of the estimation? To retrospectively characterize past conditions? To predict future power generation at one location? To predict power generation within a grid of turbines? To calibrate a meteorological model? Etc. For this question, determining an appropriate solution depends critically on how it will be used. $\endgroup$ – whuber Mar 30 '11 at 17:22
  • $\begingroup$ @whuber at present the idea is to summarise wind data sets in a form allowing comparison from period to period and/or site to site. Later the goal will be compare trends and as you say to form judgements as to future production, etc. I am very much a newbie to stats but I have a mountain of data (which I can't share) and would like to extract as much information from it as possible. If you can point me to any reading on this subject it would be much appreciated. $\endgroup$ – klonq Mar 31 '11 at 7:02

Maximum Likelihood Estimation of Weibull parameters may be a good idea in your case. A form of Weibull distribution looks like this:

$$(\gamma / \theta) (x)^{\gamma-1}\exp(-x^{\gamma}/\theta)$$

Where $\theta, \gamma > 0$ are parameters. Given observations $X_1, \ldots, X_n$, the log-likelihood function is

$$L(\theta, \gamma)=\displaystyle \sum_{i=1}^{n}\log f(X_i| \theta, \gamma)$$

One "programming based" solution would be optimize this function using constrained optimization. Solving for optimum solution:

$$\frac {\partial \log L} {\partial \gamma} = \frac{n}{\gamma} + \sum_1^n \log x_i - \frac{1}{\theta}\sum_1^nx_i^{\gamma}\log x_i = 0 $$ $$\frac {\partial \log L} {\partial \theta} = -\frac{n}{\theta} + \frac{1}{\theta^2}\sum_1^nx_i^{\gamma}=0$$

On eliminating $\theta$ we get:

$$\Bigg[ \frac {\sum_1^n x_i^{\gamma} \log x_i}{\sum_1^n x_i^{\gamma}} - \frac {1}{\gamma}\Bigg]=\frac{1}{n}\sum_1^n \log x_i$$

Now this can be solved for ML estimate $\hat \gamma$. This can be accomplished with the aid of standard iterative procedures which solve are used to find the solution of equation such as -- Newton-Raphson or other numerical procedures.

Now $\theta$ can be found in terms of $\hat \gamma$ as:

$$\hat \theta = \frac {\sum_1^n x_i^{\hat \gamma}}{n}$$

| cite | improve this answer | |
  • $\begingroup$ One thing I would be cautious of is that it sounds like we have time-series data here. If the data are sampled over a short time frame, assuming independence could be hazardous. That said, (+1). $\endgroup$ – cardinal Mar 30 '11 at 13:09
  • $\begingroup$ @cardinal Please explain. The data ranges over the course of a month or up to a year, but sampled regularly (10 minutes). What might this imply? $\endgroup$ – klonq Mar 30 '11 at 13:48
  • $\begingroup$ @cardinal Thanks for pointing it out. I wasn't sure either if independence assumption is appropriate. $\endgroup$ – suncoolsu Mar 30 '11 at 13:58
  • 1
    $\begingroup$ @klonq, how is the sample taken? Is it the average speed over the ten minutes between recordings? Over one minute prior to recording? The instantaneous speed at the time of recording? Mostly I'd be looking for serial correlations, which could reduce your effective sample size considerably. Using an ML estimate based on an assumption of independent samples may or may not still give you a good estimate in that context, and special care should be taken regarding any inference based on the estimate. Suncoolsu's approach definitely provides a first line of attack, though. $\endgroup$ – cardinal Mar 30 '11 at 14:06
  • $\begingroup$ @klonq -- If possible, can you please describe how was your sample collected? What does the data look like? $\endgroup$ – suncoolsu Mar 30 '11 at 14:13

Use fitdistrplus:

Need help identifying a distribution by its histogram

Here's an example of how the Weibull Distribution is fit:


#Generate fake data
shape <- 1.9
x <- rweibull(n=1000, shape=shape, scale=1)

#Fit x data with fitdist
fit.w <- fitdist(x, "weibull")

Fitting of the distribution ' weibull ' by maximum likelihood 
Parameters : 
       estimate Std. Error
shape 1.8720133 0.04596699
scale 0.9976703 0.01776794
Loglikelihood:  -636.1181   AIC:  1276.236   BIC:  1286.052 
Correlation matrix:
          shape     scale
shape 1.0000000 0.3166085
scale 0.3166085 1.0000000

enter image description here

| cite | improve this answer | |
  • $\begingroup$ Thanks, but I am trying to find a solution in Java. $\endgroup$ – klonq Mar 30 '11 at 14:40
  • $\begingroup$ any pointers in R coding to get shape and scale factors? Thanks. $\endgroup$ – user56416 Sep 25 '14 at 9:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.