3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Skew Normal Distribution</title>
5 <link rel="stylesheet" href="../../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../index.html" title="Math Toolkit 2.11.0">
8 <link rel="up" href="../dists.html" title="Distributions">
9 <link rel="prev" href="rayleigh.html" title="Rayleigh Distribution">
10 <link rel="next" href="students_t_dist.html" title="Students t Distribution">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="rayleigh.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="students_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="math_toolkit.dist_ref.dists.skew_normal_dist"></a><a class="link" href="skew_normal_dist.html" title="Skew Normal Distribution">Skew
28 Normal Distribution</a>
29 </h4></div></div></div>
30 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">skew_normal</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre>
31 <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
33 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span>
34 <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 20. Policies: Controlling Precision, Error Handling etc">Policy</a> <span class="special">=</span> <a class="link" href="../../pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy<></a> <span class="special">></span>
35 <span class="keyword">class</span> <span class="identifier">skew_normal_distribution</span><span class="special">;</span>
37 <span class="keyword">typedef</span> <span class="identifier">skew_normal_distribution</span><span class="special"><></span> <span class="identifier">normal</span><span class="special">;</span>
39 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 20. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
40 <span class="keyword">class</span> <span class="identifier">skew_normal_distribution</span>
41 <span class="special">{</span>
42 <span class="keyword">public</span><span class="special">:</span>
43 <span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
44 <span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
45 <span class="comment">// Constructor:</span>
46 <span class="identifier">skew_normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
47 <span class="comment">// Accessors:</span>
48 <span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// mean if normal.</span>
49 <span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// width, standard deviation if normal.</span>
50 <span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// The distribution is right skewed if shape > 0 and is left skewed if shape < 0.</span>
51 <span class="comment">// The distribution is normal if shape is zero.</span>
52 <span class="special">};</span>
54 <span class="special">}}</span> <span class="comment">// namespaces</span>
57 The skew normal distribution is a variant of the most well known Gaussian
58 statistical distribution.
61 The skew normal distribution with shape zero resembles the <a href="http://en.wikipedia.org/wiki/Normal_distribution" target="_top">Normal
62 Distribution</a>, hence the latter can be regarded as a special case
63 of the more generic skew normal distribution.
66 If the standard (mean = 0, scale = 1) normal distribution probability density
69 <div class="blockquote"><blockquote class="blockquote"><p>
70 <span class="inlinemediaobject"><img src="../../../../equations/normal01_pdf.svg"></span>
72 </p></blockquote></div>
74 and the cumulative distribution function
76 <div class="blockquote"><blockquote class="blockquote"><p>
77 <span class="inlinemediaobject"><img src="../../../../equations/normal01_cdf.svg"></span>
79 </p></blockquote></div>
81 then the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">PDF</a>
82 of the <a href="http://en.wikipedia.org/wiki/Skew_normal_distribution" target="_top">skew
83 normal distribution</a> with shape parameter α, defined by O'Hagan and
86 <div class="blockquote"><blockquote class="blockquote"><p>
87 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf0.svg"></span>
89 </p></blockquote></div>
91 Given <a href="http://en.wikipedia.org/wiki/Location_parameter" target="_top">location</a>
92 ξ, <a href="http://en.wikipedia.org/wiki/Scale_parameter" target="_top">scale</a>
93 ω, and <a href="http://en.wikipedia.org/wiki/Shape_parameter" target="_top">shape</a>
94 α, it can be <a href="http://en.wikipedia.org/wiki/Skew_normal_distribution" target="_top">transformed</a>,
97 <div class="blockquote"><blockquote class="blockquote"><p>
98 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf.svg"></span>
100 </p></blockquote></div>
102 and <a href="http://en.wikipedia.org/wiki/Cumulative_distribution_function" target="_top">CDF</a>:
104 <div class="blockquote"><blockquote class="blockquote"><p>
105 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_cdf.svg"></span>
107 </p></blockquote></div>
109 where <span class="emphasis"><em>T(h,a)</em></span> is Owen's T function, and <span class="emphasis"><em>Φ(x)</em></span>
110 is the normal distribution.
113 The variation the PDF and CDF with its parameters is illustrated in the
116 <div class="blockquote"><blockquote class="blockquote"><p>
117 <span class="inlinemediaobject"><img src="../../../../graphs/skew_normal_pdf.svg" align="middle"></span>
119 </p></blockquote></div>
120 <div class="blockquote"><blockquote class="blockquote"><p>
121 <span class="inlinemediaobject"><img src="../../../../graphs/skew_normal_cdf.svg" align="middle"></span>
123 </p></blockquote></div>
125 <a name="math_toolkit.dist_ref.dists.skew_normal_dist.h0"></a>
126 <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.member_functions"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.member_functions">Member
129 <pre class="programlisting"><span class="identifier">skew_normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
132 Constructs a skew_normal distribution with location ξ, scale ω and shape α.
135 Requires scale > 0, otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
138 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
141 returns the location ξ of this distribution,
143 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
146 returns the scale ω of this distribution,
148 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
151 returns the shape α of this distribution.
154 (Location and scale function match other similar distributions, allowing
155 the functions <code class="computeroutput"><span class="identifier">find_location</span></code>
156 and <code class="computeroutput"><span class="identifier">find_scale</span></code> to be used
159 <div class="note"><table border="0" summary="Note">
161 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
162 <th align="left">Note</th>
164 <tr><td align="left" valign="top">
166 While the shape parameter may be chosen arbitrarily (finite), the resulting
167 <span class="bold"><strong>skewness</strong></span> of the distribution is in fact
168 limited to about (-1, 1); strictly, the interval is (-0.9952717, 0.9952717).
171 A parameter δ is related to the shape α by δ = α / (1 + α²), and used in the expression
174 <div class="blockquote"><blockquote class="blockquote"><p>
175 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_skewness.svg"></span>
177 </p></blockquote></div>
181 <a name="math_toolkit.dist_ref.dists.skew_normal_dist.h1"></a>
182 <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.references"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.references">References</a>
184 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
185 <li class="listitem">
186 <a href="http://azzalini.stat.unipd.it/SN/" target="_top">Skew-Normal Probability
187 Distribution</a> for many links and bibliography.
189 <li class="listitem">
190 <a href="http://azzalini.stat.unipd.it/SN/Intro/intro.html" target="_top">A very
191 brief introduction to the skew-normal distribution</a> by Adelchi
192 Azzalini (2005-11-2).
194 <li class="listitem">
195 See a <a href="http://www.tri.org.au/azzalini.html" target="_top">skew-normal
196 function animation</a>.
200 <a name="math_toolkit.dist_ref.dists.skew_normal_dist.h2"></a>
201 <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.non_member_accessors"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.non_member_accessors">Non-member
205 All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
206 functions</a> that are generic to all distributions are supported:
207 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
208 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
209 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
210 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.median">median</a>,
211 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>,
212 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
213 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>,
214 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
217 The domain of the random variable is <span class="emphasis"><em>-[max_value], +[min_value]</em></span>.
218 Infinite values are not supported.
221 There are no <a href="http://en.wikipedia.org/wiki/Closed-form_expression" target="_top">closed-form
222 expression</a> known for the mode and median, but these are computed
225 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
226 <li class="listitem">
227 mode - by finding the maximum of the PDF.
229 <li class="listitem">
230 median - by computing <code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="number">1</span><span class="special">/</span><span class="number">2</span><span class="special">)</span></code>.
234 The maximum of the PDF is sought through searching the root of f'(x)=0.
237 Both involve iterative methods that will have lower accuracy than other
241 <a name="math_toolkit.dist_ref.dists.skew_normal_dist.h3"></a>
242 <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.testing"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.testing">Testing</a>
245 <a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>
246 using library(sn) described at <a href="http://azzalini.stat.unipd.it/SN/" target="_top">Skew-Normal
247 Probability Distribution</a>, and at <a href="http://cran.r-project.org/web/packages/sn/sn.pd" target="_top">R
248 skew-normal(sn) package</a>.
251 Package sn provides functions related to the skew-normal (SN) and the skew-t
252 (ST) probability distributions, both for the univariate and for the the
253 multivariate case, including regression models.
256 <a href="http://www.wolfram.com/products/mathematica/index.html" target="_top">Wolfram
257 Mathematica</a> was also used to generate some more accurate spot test
261 <a name="math_toolkit.dist_ref.dists.skew_normal_dist.h4"></a>
262 <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.accuracy"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.accuracy">Accuracy</a>
265 The skew_normal distribution with shape = zero is implemented as a special
266 case, equivalent to the normal distribution in terms of the <a class="link" href="../../sf_erf/error_function.html" title="Error Function erf and complement erfc">error
267 function</a>, and therefore should have excellent accuracy.
270 The PDF and mean, variance, skewness and kurtosis are also accurately evaluated
271 using <a href="http://en.wikipedia.org/wiki/Analytical_expression" target="_top">analytical
272 expressions</a>. The CDF requires <a href="http://en.wikipedia.org/wiki/Owen%27s_T_function" target="_top">Owen's
273 T function</a> that is evaluated using a Boost C++ <a class="link" href="../../owens_t.html" title="Owen's T function">Owens
274 T</a> implementation of the algorithms of M. Patefield and D. Tandy,
275 Journal of Statistical Software, 5(5), 1-25 (2000); the complicated accuracy
276 of this function is discussed in detail at <a class="link" href="../../owens_t.html" title="Owen's T function">Owens
280 The median and mode are calculated by iterative root finding, and both
281 will be less accurate.
284 <a name="math_toolkit.dist_ref.dists.skew_normal_dist.h5"></a>
285 <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.implementation"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.implementation">Implementation</a>
288 In the following table, ξ is the location of the distribution, and ω is its
289 scale, and α is its shape.
291 <div class="informaltable"><table class="table">
319 <div class="blockquote"><blockquote class="blockquote"><p>
320 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf.svg"></span>
322 </p></blockquote></div>
335 <div class="blockquote"><blockquote class="blockquote"><p>
336 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_cdf.svg"></span>
338 </p></blockquote></div>
340 <br> where <span class="emphasis"><em>T(h,a)</em></span> is Owen's T function,
341 and <span class="emphasis"><em>Φ(x)</em></span> is the normal distribution.
353 Using: complement of normal distribution + 2 * Owens_t
365 Maximum of the pdf is sought through searching the root of f'(x)=0
372 quantile from the complement
377 -quantile(SN(-location ξ, scale ω, -shapeα), p)
436 <div class="blockquote"><blockquote class="blockquote"><p>
437 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_mean.svg"></span>
439 </p></blockquote></div>
450 Maximum of the pdf is sought through searching the root of f'(x)=0
461 <div class="blockquote"><blockquote class="blockquote"><p>
462 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_variance.svg"></span>
464 </p></blockquote></div>
474 <div class="blockquote"><blockquote class="blockquote"><p>
475 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_skewness.svg"></span>
477 </p></blockquote></div>
499 <div class="blockquote"><blockquote class="blockquote"><p>
500 <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_kurt_ex.svg"></span>
502 </p></blockquote></div>
508 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
509 <td align="left"></td>
510 <td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
511 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
512 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
513 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
514 Daryle Walker and Xiaogang Zhang<p>
515 Distributed under the Boost Software License, Version 1.0. (See accompanying
516 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
521 <div class="spirit-nav">
522 <a accesskey="p" href="rayleigh.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="students_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>