Fitting Wave Height Data to a Probability Distribution - Maple Help

Home : Support : Online Help : Applications and Example Worksheets : Science and Engineering : Fitting Wave Height Data to a Probability Distribution

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

The Google Maps component below gives the location of buoy PR206.

 Latitude Longitude Zoom Level Map Type roadmapsatelliteterrainhybrid 

Download and Plot Significant Wave Height Data in a Histogram

 > $\mathrm{restart}:$
 > $\mathrm{with}\left(\mathrm{plots}\right):\mathrm{with}\left(\mathrm{Statistics}\right):\mathrm{with}\left(\mathrm{Optimization}\right):$
 > $\mathrm{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":$
 > $\mathrm{data}≔\mathrm{ImportMatrix}\left(\mathrm{url}\right)$
 ${\mathrm{data}}{≔}\left[\begin{array}{c}{\mathrm{8274 x 6}}{\mathrm{Matrix}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (2.1)
 > $\mathrm{sigWaveHeight}≔\mathrm{RemoveNonNumeric}\left(\mathrm{data}\left[..,2\right]\right):$
 > $\mathrm{n}≔\mathrm{numelems}\left(\mathrm{sigWaveHeight}\right)$
 ${n}{≔}{8273}$ (2.2)
 > $\mathrm{numBins}≔40:$
 > $\mathrm{p1}≔\mathrm{Histogram}\left(\mathrm{sigWaveHeight},\mathrm{bincount}=\mathrm{numBins},\mathrm{color}=\mathrm{COLOR}\left(\mathrm{RGB},\frac{150}{255},\frac{40}{255},\frac{27}{255}\right),\mathrm{thickness}=0,\mathrm{style}=\mathrm{patchnogrid},\mathrm{transparency}=0.5,\mathrm{background}=\mathrm{ColorTools}:-\mathrm{Color}\left("RGB",\left[\frac{236}{255},\frac{240}{255},\frac{241}{255}\right]\right),\mathrm{axis}=\left[\mathrm{gridlines}=\left[10,\mathrm{color}=\mathrm{RGB}\left(1,1,1\right)\right]\right],\mathrm{axesfont}=\left[\mathrm{Arial}\right],\mathrm{labels}=\left["Significant Wave Height \left(m\right)","Distribution"\right],\mathrm{labeldirections}=\left[\mathrm{horizontal},\mathrm{vertical}\right],\mathrm{labelfont}=\left[\mathrm{Arial}\right],\mathrm{size}=\left[800,500\right]\right):$
 > $\mathrm{display}\left(\mathrm{p1}\right)$

Maximum Likelihood Estimation

 > $\mathrm{P}≔\mathrm{unapply}\left(\mathrm{ProbabilityDensityFunction}\left(\mathrm{Weibull}\left(\mathrm{alpha},\mathrm{beta}\right),\mathrm{t}\right),\mathrm{t},\mathrm{alpha},\mathrm{beta}\right)$
 ${P}{≔}\left({t}{,}{\mathrm{\alpha }}{,}{\mathrm{\beta }}\right){↦}\left\{\begin{array}{cc}{0}& {t}{<}{0}\\ \frac{{\mathrm{\beta }}{}{{t}}^{{-}{1}{+}{\mathrm{\beta }}}{}{{ⅇ}}^{{-}{\left(\frac{{t}}{{\mathrm{\alpha }}}\right)}^{{\mathrm{\beta }}}}}{{{\mathrm{\alpha }}}^{{\mathrm{\beta }}}}& {\mathrm{otherwise}}\end{array}\right\$ (3.1)
 > $\mathrm{maxLike}:=\left(\mathrm{\alpha },\mathrm{\beta }\right)\to \mathrm{add}\left(\mathrm{ln}\left(\mathrm{P}\left({\mathrm{sigWaveHeight}}_{\mathrm{i}},\mathrm{\alpha },\mathrm{\beta }\right)\right),\mathrm{i}=1..\mathrm{n}\right):$
 > $\mathrm{resultsMLE}≔\mathrm{Maximize}\left(\mathrm{maxLike}\left(\mathrm{\alpha },\mathrm{\beta }\right),\mathrm{α}=0.01..5,\mathrm{β}=0.01..5\right)$
 ${\mathrm{resultsMLE}}{≔}\left[{-4839.27465547207703}{,}\left[{\mathrm{\alpha }}{=}{1.34452570778020}{,}{\mathrm{\beta }}{=}{2.83250005643047}\right]\right]$ (3.2)
 >

Moment Matching

 > $\mathrm{resultsMM}:=\mathrm{fsolve}\left(\left[\mathrm{Moment}\left(\mathrm{sigWaveHeight},1\right)=\mathrm{Moment}\left(\mathrm{Weibull}\left(\mathrm{α},\mathrm{β}\right),1\right),\mathrm{Moment}\left(\mathrm{sigWaveHeight},2\right)=\mathrm{Moment}\left(\mathrm{Weibull}\left(\mathrm{α},\mathrm{β}\right),2\right)\right],\left\{\mathrm{α}=1,\mathrm{β}=1\right\}\right)$
 ${\mathrm{resultsMM}}{≔}\left\{{\mathrm{\alpha }}{=}{1.342796022}{,}{\mathrm{\beta }}{=}{2.958762705}\right\}$ (4.1)
 >

Results

 > $\mathrm{display}\left(\mathrm{p1},\mathrm{p2},\mathrm{p3},\mathrm{size}=\left[800,500\right]\right)$
 >