| <!-- HTML header for doxygen 1.8.4--> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| <meta name="generator" content="Doxygen 1.8.10"/> |
| <meta name="keywords" content="madlib,postgres,greenplum,machine learning,data mining,deep learning,ensemble methods,data science,market basket analysis,affinity analysis,pca,lda,regression,elastic net,huber white,proportional hazards,k-means,latent dirichlet allocation,bayes,support vector machines,svm"/> |
| <title>MADlib: Probability Functions</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <link href="navtree.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="resize.js"></script> |
| <script type="text/javascript" src="navtreedata.js"></script> |
| <script type="text/javascript" src="navtree.js"></script> |
| <script type="text/javascript"> |
| $(document).ready(initResizable); |
| $(window).load(resizeHeight); |
| </script> |
| <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="search/searchdata.js"></script> |
| <script type="text/javascript" src="search/search.js"></script> |
| <script type="text/javascript"> |
| $(document).ready(function() { init_search(); }); |
| </script> |
| <!-- hack in the navigation tree --> |
| <script type="text/javascript" src="eigen_navtree_hacks.js"></script> |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| <link href="madlib_extra.css" rel="stylesheet" type="text/css"/> |
| <!-- google analytics --> |
| <script> |
| (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
| ga('create', 'UA-45382226-1', 'madlib.net'); |
| ga('send', 'pageview'); |
| </script> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| <div id="titlearea"> |
| <table cellspacing="0" cellpadding="0"> |
| <tbody> |
| <tr style="height: 56px;"> |
| <td id="projectlogo"><a href="http://madlib.net"><img alt="Logo" src="madlib.png" height="50" style="padding-left:0.5em;" border="0"/ ></a></td> |
| <td style="padding-left: 0.5em;"> |
| <div id="projectname"> |
| <span id="projectnumber">1.9</span> |
| </div> |
| <div id="projectbrief">User Documentation for MADlib</div> |
| </td> |
| <td> <div id="MSearchBox" class="MSearchBoxInactive"> |
| <span class="left"> |
| <img id="MSearchSelect" src="search/mag_sel.png" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| alt=""/> |
| <input type="text" id="MSearchField" value="Search" accesskey="S" |
| onfocus="searchBox.OnSearchFieldFocus(true)" |
| onblur="searchBox.OnSearchFieldFocus(false)" |
| onkeyup="searchBox.OnSearchFieldChange(event)"/> |
| </span><span class="right"> |
| <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> |
| </span> |
| </div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.8.10 --> |
| <script type="text/javascript"> |
| var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| </script> |
| </div><!-- top --> |
| <div id="side-nav" class="ui-resizable side-nav-resizable"> |
| <div id="nav-tree"> |
| <div id="nav-tree-contents"> |
| <div id="nav-sync" class="sync"></div> |
| </div> |
| </div> |
| <div id="splitbar" style="-moz-user-select:none;" |
| class="ui-resizable-handle"> |
| </div> |
| </div> |
| <script type="text/javascript"> |
| $(document).ready(function(){initNavTree('group__grp__prob.html','');}); |
| </script> |
| <div id="doc-content"> |
| <!-- window showing the filter options --> |
| <div id="MSearchSelectWindow" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| </div> |
| |
| <!-- iframe showing the search results (closed by default) --> |
| <div id="MSearchResultsWindow"> |
| <iframe src="javascript:void(0)" frameborder="0" |
| name="MSearchResults" id="MSearchResults"> |
| </iframe> |
| </div> |
| |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">Probability Functions<div class="ingroups"><a class="el" href="group__grp__stats.html">Statistics</a></div></div> </div> |
| </div><!--header--> |
| <div class="contents"> |
| <div class="toc"><b>Contents</b> </p><ul> |
| <li> |
| <a href="#syntax">Function Syntax</a> </li> |
| <li> |
| <a href="#examples">Examples</a> </li> |
| <li> |
| <a href="#literature">Literature</a> </li> |
| <li> |
| <a href="#related">Related Topics</a> </li> |
| </ul> |
| </div><p>The Probability Functions module provides cumulative distribution, density/mass, and quantile functions for a wide range of probability distributions.</p> |
| <p>Unless otherwise documented, all of these functions are wrappers around functionality provided by the boost C++ library [1, “<a href="http://www.boost.org/doc/libs/1_49_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist.html">Statistical Distributions and Functions</a>”].</p> |
| <p>For convenience, all cumulative distribution and density/mass functions (CDFs and PDF/PMFs in short) are defined over the range of all floating-point numbers including infinity. Inputs that are <code>NULL</code> or <code>NaN</code> (not a number) will always produce a <code>NULL</code> or <code>NaN</code> result, respectively. Inputs that are plus or minus infinity will return the respective limits.</p> |
| <p>A quantile function for a probability distrution with CDF <img class="formulaInl" alt="$ F $" src="form_112.png"/> takes a probability argument <img class="formulaInl" alt="$ p \in [0,1] $" src="form_240.png"/> and returns the value <img class="formulaInl" alt="$ x $" src="form_178.png"/> so that <img class="formulaInl" alt="$ F(x) = p $" src="form_241.png"/>, provided such an <img class="formulaInl" alt="$ x $" src="form_178.png"/> exists and it is unique. If it does not, the result will be <img class="formulaInl" alt="$ \sup \{ x \in D \mid F(x) \leq p \} $" src="form_242.png"/> (interpreted as 0 if the supremum is over an empty set) if <img class="formulaInl" alt="$ p < 0.5 $" src="form_243.png"/>, and <img class="formulaInl" alt="$ \inf \{ x \in D \mid F(x) \geq p \} $" src="form_244.png"/> if <img class="formulaInl" alt="$ p \geq 0.5 $" src="form_245.png"/>. Here <img class="formulaInl" alt="$ D $" src="form_246.png"/> denotes the domain of the distribution, which is the set of reals <img class="formulaInl" alt="$ \mathbb R $" src="form_247.png"/> for continuous and the set of nonnegative integers <img class="formulaInl" alt="$ \mathbb N_0 $" src="form_248.png"/> for discrete distributions.</p> |
| <p>Intuitively, the formulas in the previous paragraph deal with the following special cases. The 0-quantile will always be the “left end” of the support, and the 1-quantile will be the “right end” of the support of the distribution. For discrete distributions, most values of <img class="formulaInl" alt="$ p \in [0,1] $" src="form_240.png"/> do not admit an <img class="formulaInl" alt="$ x $" src="form_178.png"/> with <img class="formulaInl" alt="$ F(x) = p $" src="form_241.png"/>. Instead, there is an <img class="formulaInl" alt="$ x \in \mathbb N_0 $" src="form_249.png"/> so that <img class="formulaInl" alt="$ F(x) < p < F(x + 1) $" src="form_250.png"/>. The above formulas mean that the value returned as <img class="formulaInl" alt="$ p $" src="form_110.png"/>-quantile is <img class="formulaInl" alt="$ x $" src="form_178.png"/> if <img class="formulaInl" alt="$ p < 0.5 $" src="form_243.png"/>, and it is <img class="formulaInl" alt="$ x + 1 $" src="form_251.png"/> if <img class="formulaInl" alt="$ p \geq 0.5 $" src="form_245.png"/>. (As a special case, in order to ensure that quantiles are always within the support, the <img class="formulaInl" alt="$ p $" src="form_110.png"/>-quantile will be 0 if <img class="formulaInl" alt="$ p < F(0) $" src="form_252.png"/>).</p> |
| <p>The rationale for choosing this behavior is that <img class="formulaInl" alt="$p$" src="form_253.png"/>-quantiles for <img class="formulaInl" alt="$ p < 0.5 $" src="form_243.png"/> are typically requested when interested in the value <img class="formulaInl" alt="$ x $" src="form_178.png"/> such that with confidence level <b>at least</b> <img class="formulaInl" alt="$ 1 - p $" src="form_254.png"/> a random variable will be <img class="formulaInl" alt="$ > x $" src="form_255.png"/> (or equivalently, with probability <b>at most</b> <img class="formulaInl" alt="$ p $" src="form_110.png"/>, it will be <img class="formulaInl" alt="$ \leq x $" src="form_256.png"/>). Likewise, <img class="formulaInl" alt="$p$" src="form_253.png"/>-quantiles for <img class="formulaInl" alt="$ p \geq 0.5 $" src="form_245.png"/> are typically requested when interested in the value <img class="formulaInl" alt="$ x $" src="form_178.png"/> such that with confidence level <b>at least</b> <img class="formulaInl" alt="$ p $" src="form_110.png"/> a random variable will be <img class="formulaInl" alt="$ \leq x $" src="form_256.png"/>. See also [1, “<a href="http://www.boost.org/doc/libs/1_46_1/libs/math/doc/sf_and_dist/html/math_toolkit/policy/pol_tutorial/understand_dis_quant.html">Understanding Quantiles of Discrete Distributions</a>”].</p> |
| <p><a class="anchor" id="syntax"></a></p><dl class="section user"><dt>Function Syntax</dt><dd></dd></dl> |
| <p>Cumulative distribution functions:</p> |
| <pre class="syntax"><em>distribution</em>_cdf(<em>random variate</em>[, <em>parameter1</em> [, <em>parameter2</em> [, <em>parameter3</em>] ] ])</pre><p>Probability density/mass functions: </p><pre class="syntax"><em>distribution</em>_{pdf|pmf}(<em>random variate</em>[, <em>parameter1</em> [, <em>parameter2</em> [, <em>parameter3</em>] ] ])</pre><p>Quantile functions: </p><pre class="syntax"><em>distribution</em>_quantile(<em>probability</em>[, <em>parameter1</em> [, <em>parameter2</em> [, <em>parameter3</em>] ] ])</pre><p>For concrete function signatures, see <a class="el" href="prob_8sql__in.html">prob.sql_in</a>.</p> |
| <p><a class="anchor" id="examples"></a></p><dl class="section user"><dt>Examples</dt><dd></dd></dl> |
| <pre class="example"> |
| SELECT madlib.normal_cdf(0); |
| </pre><p> Result: </p><pre class="result"> |
| normal_cdf |
|  ----------- |
| 0.5 |
| </pre> <pre class="example"> |
| SELECT madlib.normal_quantile(0.5, 0, 1); |
| </pre><p> Result: </p><pre class="result"> |
| normal_quantile |
|  ---------------- |
| 0 |
| (1 row) |
| </pre><p><a class="anchor" id="literature"></a></p><dl class="section user"><dt>Literature</dt><dd></dd></dl> |
| <p>[1] John Maddock, Paul A. Bristow, Hubert Holin, Xiaogang Zhang, Bruno Lalande, Johan Råde, Gautam Sewani and Thijs van den Berg: <em>Boost Math Toolkit</em>, Version 1.49, available at: <a href="http://www.boost.org/doc/libs/1_49_0/libs/math/doc/sf_and_dist/html/index.html">http://www.boost.org/doc/libs/1_49_0/libs/math/doc/sf_and_dist/html/index.html</a></p> |
| <dl class="section user"><dt>Related Topics</dt><dd><a class="anchor" id="related"></a>File <a class="el" href="prob_8sql__in.html" title="SQL functions for evaluating probability functions. ">prob.sql_in</a> documenting the SQL functions. </dd></dl> |
| </div><!-- contents --> |
| </div><!-- doc-content --> |
| <!-- start footer part --> |
| <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| <ul> |
| <li class="footer">Generated on Thu Apr 7 2016 14:24:10 for MADlib by |
| <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.10 </li> |
| </ul> |
| </div> |
| </body> |
| </html> |