Hi i am analaysing wind data for estimating energy from a wind turbine.
I have taken 10 years of wind data and graphed a histogram;
my second stage was to fit a Weibull distribution to the data.
I used R with the package lmom to compute the Weibul shape and scale this is the code i used:

x.wei<-rweibull(n=length(pp$WS), shape=moments["delta"], scale=moments["beta"])    
hist(as.numeric(pp$WS), freq=FALSE)    
lines(density(x.wei), col="red", lwd=4)    

It seems like there is some lag between the data and the density function; can you help me with this? Another question is can you help me in calculating the anual energy from the density function?

enter image description here
thank you

  • $\begingroup$ About the picture, post to some image hosting and put a link -- I'll convert it into a pasted-in picture. $\endgroup$
    – user88
    Feb 13, 2011 at 8:35
  • $\begingroup$ +1, interesting question, you might find that soon you will have enough reputation :) $\endgroup$
    – mpiktas
    Feb 13, 2011 at 8:46
  • 2
    $\begingroup$ judging from the graph, the problem is not the lag. What you have plotted is roughly goodness of fit. So it seems that Weibull distribution is not apropriate for your data. I see that there is a bunch up near zero, do you have zero values in your data? In that case you will need to model zero values separately. So first suggestion would be to try Weibull for non zero values. Also why Weibull, is there particular reason, some reference from similar work perhaps? $\endgroup$
    – mpiktas
    Feb 13, 2011 at 9:02
  • 1
    $\begingroup$ note that 'lag' is a term used mainly in analysis of data in time, referring to one thing occurring after another. This isn't a lag - it's perhaps more accurately called a shift - or maybe an offset - but shift is probably more common for distributions, they shift and scale. $\endgroup$
    – Spacedman
    Feb 13, 2011 at 10:28
  • 1
    $\begingroup$ be careful about using as.numeric(x) with factors; you actually want to use as.numeric(as.character(x)) to make sure you get the right number value for the factor. $\endgroup$ Oct 16, 2016 at 23:10

4 Answers 4


lmom function pelwei fits a three parameter Weibull distribution, with location, scale and shape parameters. rweibull generates random numbers for a two-parameter Weibull distribution. You need to subtract the location parameter moments["zeta"]. That should give a better fit, but it doesn't appear it will give a good fit to your particular data.

I notice http://www.reuk.co.uk/Wind-Speed-Distribution-Weibull.htm says "Wind speeds in most of the world can be modelled using the Weibull Distribution.". Perhaps you're just unlucky and live in a part of the world where they can't!

  • $\begingroup$ do you tink you can help me with my second question: calculating wind energy based on the density function? $\endgroup$
    – eliavs
    Feb 13, 2011 at 11:05
  • 2
    $\begingroup$ I'm not a physicist and I don't know the necessary equations, but I imagine it will involve a numerical integral over the density. R's integrate() function may be useful for that. $\endgroup$
    – onestop
    Feb 13, 2011 at 12:48
  • $\begingroup$ i know the equation my problam is i want to compute the percent of time the wind is at each speed $\endgroup$
    – eliavs
    Feb 13, 2011 at 14:18
  • $\begingroup$ what i meAn is can you help me with the integration --> thank you $\endgroup$
    – eliavs
    Feb 13, 2011 at 14:45

I recreated your plot with data from http://hawaii.gov/dbedt/ert/winddata/krab0192.txt (I took the 1200 measurements). I got a decent fit of the data, generally using your code:


daten <- read.delim("wind.txt")
wind.avg <- na.omit(as.numeric(daten[,"X12"]))
x.wei<-rweibull(n=length(wind.avg), shape=moments["delta"], scale=moments["beta"])
hist(as.numeric(wind.avg), freq=FALSE)
lines(density(x.wei), col="red", lwd=4)

Wind Plot

Sorry, I'm not shure were your problem could be, but I think you should be able to fit weibull to your data. What makes me suspicious is the bell-curve of your density plot, I have no idea where that came from.

Here are the moments I generated:


       l_1         l_2         t_3         t_4 
15.17287544  4.80372580  0.14963501  0.06954438


     zeta      beta     delta 
 0.516201 16.454233  1.745413 

WTR to the annual output: I suppose I'd generate discrete values for the probability density function, multiply these values with the output function and sum it up. Alternatively, you could just use your raw data, multiply the values with the output function, sum it up and calculate the annual average, you should control for seasonality in a suitable way (e. g. make sure to use whole years, or to weight accordingly).

Here is the uncontrolled output (using the formula from http://www.articlesbase.com/diy-articles/determining-wind-turbine-annual-power-output-a-simple-formula-based-upon-blade-diameter-and-average-wind-speed-at-your-location-513080.html)

years  <- length(wind.avg)/365
diameter <- 150
Power = (0.01328*diameter^2)*((wind.avg)^3)
(annual.power <- sum(Power)/years)
[1] 791828306

Here's a recent post at SO on wind turbines. My answer on that link has three links that you might be interested in:


I just checked one of the Weibull links in the above SO answer. For some reason, the link is down. Here are some links that provide the same basic information:






Also, from the power generated from wind, the seasonality is obvious.

enter image description here

enter image description here


I'm not sure if somebody has already made this point, but pelwei can actually be forced to work as a 2 parameter weibull function by adding in a fixed bound.

Insead of calling moments<-pelwei(wind.moments) you should simply call moments<-pelwei(wind.moments,bound=0)

you can always check what the zeta value is. If it's not 0 and you're using dweibull, you need to do something about it.


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.