Hi Andre, Well, the equation for the normal distribution of data with mean U and standard deviation S is given by a formula, http://en.wikipedia.org/wiki/Normal_distribution So start by translating that into Ferret expressions. The independent axis is the variable xx, coordinates on an axis. yes? ! General definitions for a function for normal distributionNow look at it with different mean and std. The formula is normalized so the area under the curve is always 1. yes? let s = 2So, how to define the right curve to add to your frequency_histogram plot to show the normal distribution that has the same mean and std as your data? Those who are statisticians may want to chime in on what I've done here with the scaling; I think it's correct. We'll want to reset U and S in the definition of the variable "norm", so that they are the the mean and standard deviation of the variable from the histogram. Say we're doing the histogram of sst[L=1] from coads_climatology. The mean and standard deviation of the variable can be set using the STAT command: yes? use coads_climatologyThe independent axis of the curve needs to match the histogram plot. The frequency_histogram scripts define a set of bins and compute the data counts data in those bins. After you run frequency_histogram2.jnl, you'll see the script wrote a file to store those. yes? GO frequency_histogram2 sst[L=1] -2, 32, 2 The second dataset contains the histogram bins and counts. So we'll plot normal distribution for the the sample data using an x-axis defined from bar_x. Redefine our axis xax, which will redefine xx in our variable norm. yes? define axis/x xax = bar_x[d=2]If you plot "norm" now, you'll see its vertical scale is very different from the histogram plot. The normal distribution curve is scaled so its integral is 1. We need to rescale it to have the same area under the curve as the frequency histogram. The histogram counts are represented by the numbers in bar_y. Use this variable to get the right scale factor to plot the normal distribution and the histogram plot together: yes? let y_hist = bar_y[d=2,gx=xax@asn]Finally we can plot the curve scaled to match the histogram plot yes? plot/over/color=red/thick/nolabel norm*area_histI've attached that plot. This particular data is far from being normally distributed! 11/20/2014 10:36 AM, Andre Paim wrote:
|
Attachment:
histo_with_curve.gif
Description: GIF image