Fitting Wave Height Data to a Probability Distribution
Introduction
The University of Maine records real-time accelerometer data from buoys deployed in the Gulf of Maine and the Caribbean (http://gyre.umeoce.maine.edu/buoyhome.php). The data can be downloaded from their website, and includes the significant wave height recorded at regular intervals for the last few months.
This application does the following:
Downloads accelerometer data for Buoy PR206 (located just off the coast of Puerto Rico at a latitude of 18° 28.46' N and a longitude of 66° 5.94' W)
Fits the significant wave height to a Weibull distribution by using two methods: maximum likelihood estimation and moment matching
Plots the fitted distributions on top of a histogram of the experimental data
Download and Plot Significant Wave Height Data in a Histogram
restart:
withplots:withStatistics:withOptimization:
url≔http://gyre.umeoce.maine.edu/data/gomoos/buoy/php/view_csv_file.php?ncfile=/data/gomoos/buoy/archive/PR206/realtime/PR206.waves.triaxys.realtime.nc:
data≔ImportMatrixurl
sigWaveHeight≔RemoveNonNumericdata..,2:
n≔numelemssigWaveHeight
n≔8273
numBins≔40:
p1≔HistogramsigWaveHeight,bincount=numBins,color=COLORRGB,150255,40255,27255,thickness=0,style=patchnogrid,transparency=0.5,background=ColorTools:-ColorRGB,236255,240255,241255,axis=gridlines=10,color=RGB1,1,1,axesfont=Arial,labels=Significant Wave Height (m),Distribution,labeldirections=horizontal,vertical,labelfont=Arial,size=800,500:
displayp1
Maximum Likelihood Estimation
P≔unapplyProbabilityDensityFunctionWeibullalpha,beta,t,t,alpha,beta
P≔t,α,β↦0t<0β⋅t−1+β⋅ⅇ−tαβαβotherwise
maxLike:=α,β→addlnPsigWaveHeighti,α,β,i=1..n:
Warning, (in maxLike) `i` is implicitly declared local
resultsMLE≔MaximizemaxLikeα,β,α=0.01..5,β=0.01..5
resultsMLE≔−4839.27465547207612,α=1.34452570778020,β=2.83250005643047
p2≔plotevalPt,alpha,beta,resultsMLE2 ,t=minsigWaveHeight..maxsigWaveHeight,color=black,legend=Maximum Likelihood Estimation,thickness=3,legendstyle=font=Arial:
Moment Matching
resultsMM:=fsolve⁡Moment⁡sigWaveHeight,1=Moment⁡Weibull⁡α,β,1,Moment⁡sigWaveHeight,2=Moment⁡Weibull⁡α,β,2,α=1,β=1
resultsMM≔α=1.342796022,β=2.958762705
p3≔plotevalPt,alpha,beta,resultsMM ,t=minsigWaveHeight..maxsigWaveHeight,color=RGB150255,40255,27255,thickness=3,legend=Moment Matching,legendstyle=font=Arial:
Results
displayp1,p2,p3,size=800,500
Download Help Document