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.77.1">
7 <link rel=
"home" href=
"../../../index.html" title=
"Math Toolkit 2.5.1">
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 15. 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 15. 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
70     <span class=
"inlinemediaobject"><img src=
"../../../../equations/normal01_pdf.svg"></span>
73 and the cumulative distribution function
76     <span class=
"inlinemediaobject"><img src=
"../../../../equations/normal01_cdf.svg"></span>
79 then the
<a href=
"http://en.wikipedia.org/wiki/Probability_density_function" target=
"_top">PDF
</a>
80 of the
<a href=
"http://en.wikipedia.org/wiki/Skew_normal_distribution" target=
"_top">skew
81 normal distribution
</a> with shape parameter
α, defined by O'Hagan and
85     <span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_pdf0.svg"></span>
88 Given
<a href=
"http://en.wikipedia.org/wiki/Location_parameter" target=
"_top">location
</a>
89 ξ,
<a href=
"http://en.wikipedia.org/wiki/Scale_parameter" target=
"_top">scale
</a>
90 ω, and
<a href=
"http://en.wikipedia.org/wiki/Shape_parameter" target=
"_top">shape
</a>
91 α, it can be
<a href=
"http://en.wikipedia.org/wiki/Skew_normal_distribution" target=
"_top">transformed
</a>,
95     <span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_pdf.svg"></span>
98 and
<a href=
"http://en.wikipedia.org/wiki/Cumulative_distribution_function" target=
"_top">CDF
</a>:
101     <span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_cdf.svg"></span>
104 where
<span class=
"emphasis"><em>T(h,a)
</em></span> is Owen's T function, and
<span class=
"emphasis"><em>Φ(x)
</em></span>
105 is the normal distribution.
108 The variation the PDF and CDF with its parameters is illustrated in the
112 <span class=
"inlinemediaobject"><img src=
"../../../../graphs/skew_normal_pdf.svg" align=
"middle"></span>
113 <span class=
"inlinemediaobject"><img src=
"../../../../graphs/skew_normal_cdf.svg" align=
"middle"></span>
116 <a name=
"math_toolkit.dist_ref.dists.skew_normal_dist.h0"></a>
117 <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
120 <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>
123 Constructs a skew_normal distribution with location
ξ, scale
ω and shape
α.
126 Requires scale
> 0, otherwise
<a class=
"link" href=
"../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error
</a>
129 <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>
132 returns the location
ξ of this distribution,
134 <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>
137 returns the scale
ω of this distribution,
139 <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>
142 returns the shape
α of this distribution.
145 (Location and scale function match other similar distributions, allowing
146 the functions
<code class=
"computeroutput"><span class=
"identifier">find_location
</span></code>
147 and
<code class=
"computeroutput"><span class=
"identifier">find_scale
</span></code> to be used
150 <div class=
"note"><table border=
"0" summary=
"Note">
152 <td rowspan=
"2" align=
"center" valign=
"top" width=
"25"><img alt=
"[Note]" src=
"../../../../../../../doc/src/images/note.png"></td>
153 <th align=
"left">Note
</th>
155 <tr><td align=
"left" valign=
"top">
157 While the shape parameter may be chosen arbitrarily (finite), the resulting
158 <span class=
"bold"><strong>skewness
</strong></span> of the distribution is in fact
159 limited to about (-
1,
1); strictly, the interval is (-
0.9952717,
0.9952717).
162 A parameter
δ is related to the shape
α by
δ =
α / (
1 +
α²), and used in the expression
163 for skewness
<span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_skewness.svg"></span>
169 <a name=
"math_toolkit.dist_ref.dists.skew_normal_dist.h1"></a>
170 <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>
172 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
173 <li class=
"listitem">
174 <a href=
"http://azzalini.stat.unipd.it/SN/" target=
"_top">Skew-Normal Probability
175 Distribution
</a> for many links and bibliography.
177 <li class=
"listitem">
178 <a href=
"http://azzalini.stat.unipd.it/SN/Intro/intro.html" target=
"_top">A very
179 brief introduction to the skew-normal distribution
</a> by Adelchi
180 Azzalini (
2005-
11-
2).
182 <li class=
"listitem">
183 See a
<a href=
"http://www.tri.org.au/azzalini.html" target=
"_top">skew-normal
184 function animation
</a>.
188 <a name=
"math_toolkit.dist_ref.dists.skew_normal_dist.h2"></a>
189 <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
193 All the
<a class=
"link" href=
"../nmp.html" title=
"Non-Member Properties">usual non-member accessor
194 functions
</a> that are generic to all distributions are supported:
195 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function
</a>,
196 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function
</a>,
197 <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>,
198 <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>,
199 <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>,
200 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation
</a>,
201 <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>,
202 <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>.
205 The domain of the random variable is
<span class=
"emphasis"><em>-[max_value], +[min_value]
</em></span>.
206 Infinite values are not supported.
209 There are no
<a href=
"http://en.wikipedia.org/wiki/Closed-form_expression" target=
"_top">closed-form
210 expression
</a> known for the mode and median, but these are computed
213 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
214 <li class=
"listitem">
215 mode - by finding the maximum of the PDF.
217 <li class=
"listitem">
218 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>.
222 The maximum of the PDF is sought through searching the root of f'(x)=
0.
225 Both involve iterative methods that will have lower accuracy than other
229 <a name=
"math_toolkit.dist_ref.dists.skew_normal_dist.h3"></a>
230 <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>
233 <a href=
"http://www.r-project.org/" target=
"_top">The R Project for Statistical Computing
</a>
234 using library(sn) described at
<a href=
"http://azzalini.stat.unipd.it/SN/" target=
"_top">Skew-Normal
235 Probability Distribution
</a>, and at
<a href=
"http://cran.r-project.org/web/packages/sn/sn.pd" target=
"_top">R
236 skew-normal(sn) package
</a>.
239 Package sn provides functions related to the skew-normal (SN) and the skew-t
240 (ST) probability distributions, both for the univariate and for the the
241 multivariate case, including regression models.
244 <a href=
"http://www.wolfram.com/products/mathematica/index.html" target=
"_top">Wolfram
245 Mathematica
</a> was also used to generate some more accurate spot test
249 <a name=
"math_toolkit.dist_ref.dists.skew_normal_dist.h4"></a>
250 <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>
253 The skew_normal distribution with shape = zero is implemented as a special
254 case, equivalent to the normal distribution in terms of the
<a class=
"link" href=
"../../sf_erf/error_function.html" title=
"Error Functions">error
255 function
</a>, and therefore should have excellent accuracy.
258 The PDF and mean, variance, skewness and kurtosis are also accurately evaluated
259 using
<a href=
"http://en.wikipedia.org/wiki/Analytical_expression" target=
"_top">analytical
260 expressions
</a>. The CDF requires
<a href=
"http://en.wikipedia.org/wiki/Owen%27s_T_function" target=
"_top">Owen's
261 T function
</a> that is evaluated using a Boost C++
<a class=
"link" href=
"../../owens_t.html" title=
"Owen's T function">Owens
262 T
</a> implementation of the algorithms of M. Patefield and D. Tandy,
263 Journal of Statistical Software,
5(
5),
1-
25 (
2000); the complicated accuracy
264 of this function is discussed in detail at
<a class=
"link" href=
"../../owens_t.html" title=
"Owen's T function">Owens
268 The median and mode are calculated by iterative root finding, and both
269 will be less accurate.
272 <a name=
"math_toolkit.dist_ref.dists.skew_normal_dist.h5"></a>
273 <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>
276 In the following table,
ξ is the location of the distribution, and
ω is its
277 scale, and
α is its shape.
279 <div class=
"informaltable"><table class=
"table">
305 Using:
<span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_pdf.svg"></span>
317 Using:
<span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_cdf.svg"></span><br> where
<span class=
"emphasis"><em>T(h,a)
</em></span>
318 is Owen's T function, and
<span class=
"emphasis"><em>Φ(x)
</em></span> is the normal
331 Using: complement of normal distribution +
2 * Owens_t
343 Maximum of the pdf is sought through searching the root of f'(x)=
0
350 quantile from the complement
355 -quantile(SN(-location
ξ, scale
ω, -shape
α), p)
415 <span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_mean.svg"></span>
427 Maximum of the pdf is sought through searching the root of f'(x)=
0
439 <span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_variance.svg"></span>
451 <span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_skewness.svg"></span>
475 <span class=
"inlinemediaobject"><img src=
"../../../../equations/skew_normal_kurt_ex.svg"></span>
482 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
483 <td align=
"left"></td>
484 <td align=
"right"><div class=
"copyright-footer">Copyright
© 2006-
2010,
2012-
2014 Nikhar Agrawal,
485 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
486 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R
åde, Gautam Sewani,
487 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang
<p>
488 Distributed under the Boost Software License, Version
1.0. (See accompanying
489 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>)
494 <div class=
"spirit-nav">
495 <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>