[ncl-talk] Gaussian fit line for PDF
Cathy Smith
cathy.smith at noaa.gov
Fri Mar 2 09:41:38 MST 2018
Hi
I have some code which you may be able to use with some modification.
The array xval has the x coordinates you are plotting.
undef("calcnorm")
function calcnorm (xAve,xStd,x)
local zero,one,pi,xAve,xStd,x,nor,xVar,con
begin
; normal(xAve,xStd) = [1/sqrt(2*pi)]*exp[-(0.5*(x-xAve)^2/xStd^2)
zero = 0.0d
one = 1.0d
pi = 4.0d*atan(1.0d)
con = one/(sqrt(2*pi))
xVar = xStd^2
nor = con*exp(-(((x-xAve)^2)/(2*xVar)) )
return(nor)
end
Called with
zNorm = calcnorm(0., 1.,xval)
You may need to normalize the resulting values when plotting. I
then put the 2 arrays into one data array
* datatest = new((/2,nsgs/),double)
datatest(0,:)=yvaldata
datatest(1,:)=zNorm*xbin
* xy_plot = gsn_csm_xy (wks,xval,datatest,xyres)
Cathy Smith
On 3/2/18 9:27 AM, Xi Chang wrote:
> Dear NCL,
>
> I'd like to plot PDF distribution using this function "pdfx" but
> superimposed with a Gaussian fit line of this distribution? Any
> example for this?
>
> Best,
> Chang
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
----------------------------------------------
NOAA/ESRL PSD and CU CIRES
303-497-6263
http://www.esrl.noaa.gov/psd/people/cathy.smith/
Emails about data/webpages may get quicker responses from emailing
esrl.psd.data at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180302/8b66b030/attachment.html>
More information about the ncl-talk
mailing list