MADlib
0.7 A newer version is available
User Documentation
|
00001 /* ----------------------------------------------------------------------- *//** 00002 * 00003 * @file prob.sql_in 00004 * 00005 * @brief SQL functions for evaluating probability functions 00006 * 00007 * @sa For an overview of probability functions, see the module 00008 * description \ref grp_prob. 00009 * 00010 *//* ----------------------------------------------------------------------- */ 00011 00012 m4_include(`SQLCommon.m4') 00013 00014 /** 00015 @addtogroup grp_prob 00016 00017 @about 00018 00019 The Probability Functions module provides cumulative distribution, density/mass, 00020 and quantile functions for a wide range of probability distributions. 00021 00022 Unless otherwise documented, all of these functions are wrappers around 00023 functionality provided by the boost C++ library [1, “<a href= 00024 "http://www.boost.org/doc/libs/1_49_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist.html" 00025 >Statistical Distributions and Functions</a>”]. 00026 00027 For convenience, all cumulative distribution and density/mass functions (CDFs 00028 and PDF/PMFs in short) are defined over the range of all floating-point numbers 00029 including infinity. Inputs that are \c NULL or \c NaN (not a number) will always 00030 produce a \c NULL or \c NaN result, respectively. Inputs that are plus or minus 00031 infinity will return the respective limits. 00032 00033 A quantile function for a probability distrution with CDF \f$ F \f$ takes a 00034 probability argument \f$ p \in [0,1] \f$ and returns the value \f$ x \f$ so that 00035 \f$ F(x) = p \f$, provided such an \f$ x \f$ exists and it is unique. If it does 00036 not, the result will be 00037 \f$ 00038 \sup \{ x \in D \mid F(x) \leq p \} 00039 \f$ 00040 (interpreted as 0 if the supremum is over an empty set) if \f$ p < 0.5 \f$, and 00041 \f$ 00042 \inf \{ x \in D \mid F(x) \geq p \} 00043 \f$ 00044 if \f$ p \geq 0.5 \f$. Here \f$ D \f$ denotes the domain of the distribution, 00045 which is the set of reals \f$ \mathbb R \f$ for continuous and the set of 00046 nonnegative integers \f$ \mathbb N_0 \f$ for discrete distributions. 00047 00048 Intuitively, the formulas in the previous paragraph deal with the following 00049 special cases. The 0-quantile will always be the “left end” of the support, 00050 and the 1-quantile will be the “right end” of the support of the distribution. 00051 For discrete distributions, most values of \f$ p \in [0,1] \f$ do not admit an 00052 \f$ x \f$ with \f$ F(x) = p \f$. Instead, there is an \f$ x \in \mathbb N_0 \f$ 00053 so that \f$ F(x) < p < F(x + 1) \f$. The above formulas mean that the 00054 value returned as \f$ p \f$-quantile is \f$ x \f$ if \f$ p < 0.5 \f$, and it 00055 is \f$ x + 1 \f$ if \f$ p \geq 0.5 \f$. (As a special case, in order to ensure 00056 that quantiles are always within the support, the \f$ p \f$-quantile will be 0 00057 if \f$ p < F(0) \f$). 00058 00059 The rationale for choosing this behavior is that \f$p\f$-quantiles for 00060 \f$ p < 0.5 \f$ are typically requested when interested in the value 00061 \f$ x \f$ such that with confidence level <strong>at least</strong> 00062 \f$ 1 - p \f$ a random variable will be \f$ > x \f$ (or equivalently, with 00063 probability <strong>at most</strong> \f$ p \f$, it will be \f$ \leq x \f$). 00064 Likewise, \f$p\f$-quantiles for \f$ p \geq 0.5 \f$ are typically requested when 00065 interested in the value \f$ x \f$ such that with confidence level <strong>at 00066 least</strong> \f$ p \f$ a random variable will be \f$ \leq x \f$. See also 00067 [1, “<a href= 00068 "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" 00069 >Understanding Quantiles of Discrete Distributions</a>”]. 00070 00071 @usage 00072 00073 - Cumulative distribution functions: 00074 <pre>SELECT <em>distribution</em>_cdf(<em>random variate</em>[, <em>parameter1</em> [, <em>parameter2</em> [, <em>parameter3</em>] ] ])</pre> 00075 - Probability density/mass functions: 00076 <pre>SELECT <em>distribution</em>_{pdf|pmf}(<em>random variate</em>[, <em>parameter1</em> [, <em>parameter2</em> [, <em>parameter3</em>] ] ])</pre> 00077 - Quantile functions: 00078 <pre>SELECT <em>distribution</em>_quantile(<em>probability</em>[, <em>parameter1</em> [, <em>parameter2</em> [, <em>parameter3</em>] ] ])</pre> 00079 00080 For concrete function signatures, see \ref prob.sql_in. 00081 00082 @examp 00083 00084 @verbatim 00085 sql> SELECT normal_cdf(0); 00086 normal_cdf 00087 ------------ 00088 0.5 00089 00090 sql> SELECT normal_quantile(0.5, 0, 1); 00091 normal_quantile 00092 ----------------- 00093 0 00094 (1 row) 00095 @endverbatim 00096 00097 @literature 00098 00099 [1] John Maddock, Paul A. Bristow, Hubert Holin, Xiaogang Zhang, Bruno Lalande, 00100 Johan Råde, Gautam Sewani and Thijs van den Berg: 00101 <em>Boost Math Toolkit</em>, Version 1.49, available at: 00102 http://www.boost.org/doc/libs/1_49_0/libs/math/doc/sf_and_dist/html/index.html 00103 00104 @sa File prob.sql_in documenting the SQL functions. 00105 */ 00106 00107 00108 /** 00109 * @brief Bernoulli cumulative distribution function 00110 * 00111 * @param x Random variate \f$ x \f$ 00112 * @param sp Success probability \f$ p \in [0,1] \f$ 00113 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Bernoulli-distributed 00114 * random variable with success probability \f$ \mathit{sp} \f$ 00115 */ 00116 CREATE FUNCTION MADLIB_SCHEMA.bernoulli_cdf( 00117 x DOUBLE PRECISION, 00118 sp DOUBLE PRECISION 00119 ) RETURNS DOUBLE PRECISION 00120 AS 'MODULE_PATHNAME' 00121 LANGUAGE C 00122 IMMUTABLE STRICT; 00123 00124 /** 00125 * @brief Bernoulli probability mass function 00126 * 00127 * @param x Random variate \f$ x \f$ 00128 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00129 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability mass function of 00130 * a Bernoulli-distributed random variable with success probability 00131 * \f$ \mathit{sp} \f$ 00132 */ 00133 CREATE FUNCTION MADLIB_SCHEMA.bernoulli_pmf( 00134 x INT4, 00135 sp DOUBLE PRECISION 00136 ) RETURNS DOUBLE PRECISION 00137 AS 'MODULE_PATHNAME' 00138 LANGUAGE C 00139 IMMUTABLE STRICT; 00140 00141 /** 00142 * @brief Bernoulli quantile function 00143 * 00144 * @param p Probability \f$ p \in [0,1] \f$ 00145 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00146 * @return 0 if \f$ p \leq 1 - \mathit{sp} \f$ and 1 otherwise 00147 */ 00148 CREATE FUNCTION MADLIB_SCHEMA.bernoulli_quantile( 00149 p DOUBLE PRECISION, 00150 sp DOUBLE PRECISION 00151 ) RETURNS DOUBLE PRECISION 00152 AS 'MODULE_PATHNAME' 00153 LANGUAGE C 00154 IMMUTABLE STRICT; 00155 00156 00157 /** 00158 * @brief Beta cumulative distribution function 00159 * 00160 * @param x Random variate \f$ x \f$ 00161 * @param alpha Shape \f$ \alpha > 0 \f$ 00162 * @param beta Shape \f$ \beta > 0 \f$ 00163 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a beta distributed random 00164 * variable with shape parameters \f$ \alpha \f$ and \f$ \beta \f$ 00165 */ 00166 CREATE FUNCTION MADLIB_SCHEMA.beta_cdf( 00167 x DOUBLE PRECISION, 00168 alpha DOUBLE PRECISION, 00169 beta DOUBLE PRECISION 00170 ) RETURNS DOUBLE PRECISION 00171 AS 'MODULE_PATHNAME' 00172 LANGUAGE C 00173 IMMUTABLE STRICT; 00174 00175 /** 00176 * @brief Beta probability density function 00177 * 00178 * @param x Random variate \f$ x \f$ 00179 * @param alpha Shape \f$ \alpha > 0 \f$ 00180 * @param beta Shape \f$ \beta > 0 \f$ 00181 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00182 * a beta random variable with shape parameters \f$ \alpha \f$ and 00183 * \f$ \beta \f$ 00184 */ 00185 CREATE FUNCTION MADLIB_SCHEMA.beta_pdf( 00186 x DOUBLE PRECISION, 00187 alpha DOUBLE PRECISION, 00188 beta DOUBLE PRECISION 00189 ) RETURNS DOUBLE PRECISION 00190 AS 'MODULE_PATHNAME' 00191 LANGUAGE C 00192 IMMUTABLE STRICT; 00193 00194 /** 00195 * @brief Beta quantile function 00196 * 00197 * @param p Probability \f$ p \in [0,1] \f$ 00198 * @param alpha Shape \f$ \alpha > 0 \f$ 00199 * @param beta Shape \f$ \beta > 0 \f$ 00200 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 00201 * beta distribution random variable with shape parameters \f$ \alpha \f$ 00202 * and \f$ \beta \f$ 00203 */ 00204 CREATE FUNCTION MADLIB_SCHEMA.beta_quantile( 00205 p DOUBLE PRECISION, 00206 alpha DOUBLE PRECISION, 00207 beta DOUBLE PRECISION 00208 ) RETURNS DOUBLE PRECISION 00209 AS 'MODULE_PATHNAME' 00210 LANGUAGE C 00211 IMMUTABLE STRICT; 00212 00213 00214 /** 00215 * @brief Binomial cumulative distribution function 00216 * 00217 * @param x Random variate \f$ x \f$ 00218 * @param n The number of trials \f$ n \in \mathbb N_0 \f$ 00219 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00220 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a binomially distributed 00221 * random variable with \f$ n \f$ trials and success probability 00222 * \f$ \mathit{sp} \f$ 00223 */ 00224 CREATE FUNCTION MADLIB_SCHEMA.binomial_cdf( 00225 x DOUBLE PRECISION, 00226 n INT4, 00227 sp DOUBLE PRECISION 00228 ) RETURNS DOUBLE PRECISION 00229 AS 'MODULE_PATHNAME' 00230 LANGUAGE C 00231 IMMUTABLE STRICT; 00232 00233 /** 00234 * @brief Binomial probability mass function 00235 * 00236 * @param x Random variate \f$ x \f$ 00237 * @param n The number of trials \f$ n \in \mathbb N_0 \f$ 00238 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00239 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability mass function of 00240 * a binomially distributed random variable with \f$ n \f$ trials and 00241 * success probability \f$ \mathit{sp} \f$ 00242 */ 00243 CREATE FUNCTION MADLIB_SCHEMA.binomial_pmf( 00244 x INT4, 00245 n INT4, 00246 sp DOUBLE PRECISION 00247 ) RETURNS DOUBLE PRECISION 00248 AS 'MODULE_PATHNAME' 00249 LANGUAGE C 00250 IMMUTABLE STRICT; 00251 00252 /** 00253 * @brief Binomial quantile function 00254 * 00255 * @param p Probability \f$ p \in [0,1] \f$ 00256 * @param n The number of trials \f$ n \in \mathbb N_0 \f$ 00257 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00258 * @return If \f$ p < 0.5 \f$ the maximum \f$ x \f$ such that 00259 * \f$ p \geq \Pr[X \leq x] \f$. If \f$ p \geq 0.5 \f$ the minimum \f$ x \f$ 00260 * such that \f$ p \leq \Pr[X \leq x] \f$. Here, \f$ X \f$ is a 00261 * binomially distributed random variable with \f$ n \f$ trials and 00262 * success probability \f$ \mathit{sp} \f$. 00263 */ 00264 CREATE FUNCTION MADLIB_SCHEMA.binomial_quantile( 00265 p DOUBLE PRECISION, 00266 n INT4, 00267 sp DOUBLE PRECISION 00268 ) RETURNS DOUBLE PRECISION 00269 AS 'MODULE_PATHNAME' 00270 LANGUAGE C 00271 IMMUTABLE STRICT; 00272 00273 00274 /** 00275 * @brief Cauchy cumulative distribution function 00276 * 00277 * @param x Random variate \f$ x \f$ 00278 * @param location Location \f$ x_0 \f$ 00279 * @param scale Scale \f$ \gamma > 0 \f$ 00280 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Cauchy-distributed random 00281 * variable with location and scale parameters \f$ x_0 \f$ and 00282 * \f$ \gamma \f$, respectively 00283 */ 00284 CREATE FUNCTION MADLIB_SCHEMA.cauchy_cdf( 00285 x DOUBLE PRECISION, 00286 location DOUBLE PRECISION, 00287 scale DOUBLE PRECISION 00288 ) RETURNS DOUBLE PRECISION 00289 AS 'MODULE_PATHNAME' 00290 LANGUAGE C 00291 IMMUTABLE STRICT; 00292 00293 /** 00294 * @brief Cauchy probability density function 00295 * 00296 * @param x Random variate \f$ x \f$ 00297 * @param location Location \f$ x_0 \f$ 00298 * @param scale Scale \f$ \gamma > 0 \f$ 00299 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00300 * a Cauchy-distributed random variable with location and scale parameters 00301 * \f$ x_0 \f$ and \f$ \gamma \f$, respectively 00302 */ 00303 CREATE FUNCTION MADLIB_SCHEMA.cauchy_pdf( 00304 x DOUBLE PRECISION, 00305 location DOUBLE PRECISION, 00306 scale DOUBLE PRECISION 00307 ) RETURNS DOUBLE PRECISION 00308 AS 'MODULE_PATHNAME' 00309 LANGUAGE C 00310 IMMUTABLE STRICT; 00311 00312 /** 00313 * @brief Cauchy quantile function 00314 * 00315 * @param p Probability \f$ p \in [0,1] \f$ 00316 * @param location Location \f$ x_0 \f$ 00317 * @param scale Scale \f$ \gamma > 0 \f$ 00318 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 00319 * Cauchy-distributed random variable with location and scale parameters 00320 * \f$ x_0 \f$ and \f$ \gamma \f$, respectively 00321 */ 00322 CREATE FUNCTION MADLIB_SCHEMA.cauchy_quantile( 00323 p DOUBLE PRECISION, 00324 location DOUBLE PRECISION, 00325 scale DOUBLE PRECISION 00326 ) RETURNS DOUBLE PRECISION 00327 AS 'MODULE_PATHNAME' 00328 LANGUAGE C 00329 IMMUTABLE STRICT; 00330 00331 00332 /** 00333 * @brief Chi-squared cumulative distribution function 00334 * 00335 * @param x Random variate \f$ x \f$ 00336 * @param df Degrees of freedom \f$ \nu > 0 \f$ 00337 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a chi-squared distributed 00338 * random variable with \f$ \nu \f$ degrees of freedom 00339 */ 00340 CREATE FUNCTION MADLIB_SCHEMA.chi_squared_cdf( 00341 x DOUBLE PRECISION, 00342 df DOUBLE PRECISION 00343 ) RETURNS DOUBLE PRECISION 00344 AS 'MODULE_PATHNAME' 00345 LANGUAGE C 00346 IMMUTABLE STRICT; 00347 00348 /** 00349 * @brief Chi-squared distribution probability density function 00350 * 00351 * @param x Random variate \f$ x \f$ 00352 * @param df Degrees of freedom \f$ \nu > 0 \f$ 00353 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00354 * a chi-squared distributed random variable with \f$ \nu \f$ degrees of 00355 * freedom 00356 */ 00357 CREATE FUNCTION MADLIB_SCHEMA.chi_squared_pdf( 00358 x DOUBLE PRECISION, 00359 df DOUBLE PRECISION 00360 ) RETURNS DOUBLE PRECISION 00361 AS 'MODULE_PATHNAME' 00362 LANGUAGE C 00363 IMMUTABLE STRICT; 00364 00365 /** 00366 * @brief Chi-squared distribution quantile function 00367 * 00368 * @param p Probability \f$ p \in [0,1] \f$ 00369 * @param df Degrees of freedom \f$ \mu > 0 \f$ 00370 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 00371 * chi-squared distributed random variable with \f$ \nu \f$ degrees of 00372 * freedom 00373 */ 00374 CREATE FUNCTION MADLIB_SCHEMA.chi_squared_quantile( 00375 p DOUBLE PRECISION, 00376 df DOUBLE PRECISION 00377 ) RETURNS DOUBLE PRECISION 00378 AS 'MODULE_PATHNAME' 00379 LANGUAGE C 00380 IMMUTABLE STRICT; 00381 00382 00383 /** 00384 * @brief Exponential cumulative distribution function 00385 * 00386 * @param x Random variate \f$ x \f$ 00387 * @param lambda Rate parameter \f$ \lambda > 0 \f$ 00388 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is an exponentially distributed 00389 * random variable with rate parameter \f$ \lambda \f$ 00390 */ 00391 CREATE FUNCTION MADLIB_SCHEMA.exponential_cdf( 00392 x DOUBLE PRECISION, 00393 lambda DOUBLE PRECISION 00394 ) RETURNS DOUBLE PRECISION 00395 AS 'MODULE_PATHNAME' 00396 LANGUAGE C 00397 IMMUTABLE STRICT; 00398 00399 /** 00400 * @brief Exponential probability density function 00401 * 00402 * @param x Random variate \f$ x \f$ 00403 * @param lambda Rate parameter \f$ \lambda > 0 \f$ 00404 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00405 * exponentially distributed random variable with rate parameter 00406 * \f$ \lambda \f$ 00407 */ 00408 CREATE FUNCTION MADLIB_SCHEMA.exponential_pdf( 00409 x DOUBLE PRECISION, 00410 lambda DOUBLE PRECISION 00411 ) RETURNS DOUBLE PRECISION 00412 AS 'MODULE_PATHNAME' 00413 LANGUAGE C 00414 IMMUTABLE STRICT; 00415 00416 /** 00417 * @brief Exponential quantile function 00418 * 00419 * @param p Probability \f$ p \in [0,1] \f$ 00420 * @param lambda Rate parameter \f$ \lambda > 0 \f$ 00421 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 00422 * exponentially distributed random variable with rate parameter 00423 * \f$ \lambda \f$ 00424 */ 00425 CREATE FUNCTION MADLIB_SCHEMA.exponential_quantile( 00426 p DOUBLE PRECISION, 00427 lambda DOUBLE PRECISION 00428 ) RETURNS DOUBLE PRECISION 00429 AS 'MODULE_PATHNAME' 00430 LANGUAGE C 00431 IMMUTABLE STRICT; 00432 00433 00434 /** 00435 * @brief Extreme Value cumulative distribution function 00436 * 00437 * @param x Random variate \f$ x \f$ 00438 * @param location Location \f$ \alpha \f$ 00439 * @param scale Scale \f$ \beta > 0 \f$ 00440 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is an extreme-value distributed 00441 * random variable with location and scale parameters \f$ \alpha \f$ and 00442 * \f$ \beta \f$, respectively 00443 */ 00444 CREATE FUNCTION MADLIB_SCHEMA.extreme_value_cdf( 00445 x DOUBLE PRECISION, 00446 location DOUBLE PRECISION, 00447 scale DOUBLE PRECISION 00448 ) RETURNS DOUBLE PRECISION 00449 AS 'MODULE_PATHNAME' 00450 LANGUAGE C 00451 IMMUTABLE STRICT; 00452 00453 /** 00454 * @brief Extreme Value probability density function 00455 * 00456 * @param x Random variate \f$ x \f$ 00457 * @param location Location \f$ \alpha \f$ 00458 * @param scale Scale \f$ \beta > 0 \f$ 00459 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00460 * an extreme-value distributed random variable with location and scale 00461 * parameters \f$ \alpha \f$ and \f$ \beta \f$, respectively 00462 */ 00463 CREATE FUNCTION MADLIB_SCHEMA.extreme_value_pdf( 00464 x DOUBLE PRECISION, 00465 location DOUBLE PRECISION, 00466 scale DOUBLE PRECISION 00467 ) RETURNS DOUBLE PRECISION 00468 AS 'MODULE_PATHNAME' 00469 LANGUAGE C 00470 IMMUTABLE STRICT; 00471 00472 /** 00473 * @brief Extreme Value quantile function 00474 * 00475 * @param p Probability \f$ p \in [0,1] \f$ 00476 * @param location Location \f$ \alpha \f$ 00477 * @param scale Scale \f$ \beta > 0 \f$ 00478 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 00479 * an extreme-value distributed random variable with location and scale 00480 * parameters \f$ \alpha \f$ and \f$ \beta \f$, respectively 00481 */ 00482 CREATE FUNCTION MADLIB_SCHEMA.extreme_value_quantile( 00483 p DOUBLE PRECISION, 00484 location DOUBLE PRECISION, 00485 scale DOUBLE PRECISION 00486 ) RETURNS DOUBLE PRECISION 00487 AS 'MODULE_PATHNAME' 00488 LANGUAGE C 00489 IMMUTABLE STRICT; 00490 00491 00492 /** 00493 * @brief Fisher F cumulative distribution function 00494 * 00495 * @param x Random variate \f$ x \f$ 00496 * @param df1 Degrees of freedom in numerator \f$ \nu_1 > 0 \f$ 00497 * @param df2 Degrees of freedom in denominator \f$ \nu_1 > 0 \f$ 00498 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Fisher F-distributed 00499 * random variable with parameters \f$ \nu_1 \f$ and \f$ \nu_2 \f$ 00500 */ 00501 CREATE FUNCTION MADLIB_SCHEMA.fisher_f_cdf( 00502 x DOUBLE PRECISION, 00503 df1 DOUBLE PRECISION, 00504 df2 DOUBLE PRECISION 00505 ) RETURNS DOUBLE PRECISION 00506 AS 'MODULE_PATHNAME' 00507 LANGUAGE C 00508 IMMUTABLE STRICT; 00509 00510 /** 00511 * @brief Fisher F probability density function 00512 * 00513 * @param x Random variate \f$ x \f$ 00514 * @param df1 Degrees of freedom in numerator \f$ \nu_1 > 0 \f$ 00515 * @param df2 Degrees of freedom in denominator \f$ \nu_1 > 0 \f$ 00516 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00517 * a Fisher F-distributed random variable with parameters \f$ \nu_1 \f$ and 00518 * \f$ \nu_2 \f$ 00519 */ 00520 CREATE FUNCTION MADLIB_SCHEMA.fisher_f_pdf( 00521 x DOUBLE PRECISION, 00522 df1 DOUBLE PRECISION, 00523 df2 DOUBLE PRECISION 00524 ) RETURNS DOUBLE PRECISION 00525 AS 'MODULE_PATHNAME' 00526 LANGUAGE C 00527 IMMUTABLE STRICT; 00528 00529 /** 00530 * @brief Fisher F quantile function 00531 * 00532 * @param p Probability \f$ p \in [0,1] \f$ 00533 * @param df1 Degrees of freedom in numerator \f$ \nu_1 > 0 \f$ 00534 * @param df2 Degrees of freedom in denominator \f$ \nu_1 > 0 \f$ 00535 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 00536 * Fisher F-distributed random variable with parameters \f$ \nu_1 \f$ and 00537 * \f$ \nu_2 \f$ 00538 */ 00539 CREATE FUNCTION MADLIB_SCHEMA.fisher_f_quantile( 00540 p DOUBLE PRECISION, 00541 df1 DOUBLE PRECISION, 00542 df2 DOUBLE PRECISION 00543 ) RETURNS DOUBLE PRECISION 00544 AS 'MODULE_PATHNAME' 00545 LANGUAGE C 00546 IMMUTABLE STRICT; 00547 00548 00549 /** 00550 * @brief Gamma cumulative distribution function 00551 * 00552 * @param x Random variate \f$ x \f$ 00553 * @param shape Shape \f$ k > 0 \f$ 00554 * @param scale Scale \f$ \theta > 0 \f$ 00555 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a gamma distributed random 00556 * variable with shape and scale parameters \f$ k \f$ and 00557 * \f$ \theta \f$, respectively 00558 */ 00559 CREATE FUNCTION MADLIB_SCHEMA.gamma_cdf( 00560 x DOUBLE PRECISION, 00561 shape DOUBLE PRECISION, 00562 scale DOUBLE PRECISION 00563 ) RETURNS DOUBLE PRECISION 00564 AS 'MODULE_PATHNAME' 00565 LANGUAGE C 00566 IMMUTABLE STRICT; 00567 00568 /** 00569 * @brief Gamma probability density function 00570 * 00571 * @param x Random variate \f$ x \f$ 00572 * @param shape Shape \f$ k > 0 \f$ 00573 * @param scale Scale \f$ \theta > 0 \f$ 00574 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00575 * a gamma distributed random variable with shape and scale parameters 00576 * \f$ k \f$ and \f$ \theta \f$, respectively 00577 */ 00578 CREATE FUNCTION MADLIB_SCHEMA.gamma_pdf( 00579 x DOUBLE PRECISION, 00580 shape DOUBLE PRECISION, 00581 scale DOUBLE PRECISION 00582 ) RETURNS DOUBLE PRECISION 00583 AS 'MODULE_PATHNAME' 00584 LANGUAGE C 00585 IMMUTABLE STRICT; 00586 00587 /** 00588 * @brief Gamma quantile function 00589 * 00590 * @param p Probability \f$ p \in [0,1] \f$ 00591 * @param shape Shape \f$ k > 0 \f$ 00592 * @param scale Scale \f$ \theta > 0 \f$ 00593 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 00594 * a gamma distributed random variable with shape and scale parameters 00595 * \f$ k \f$ and \f$ \theta \f$, respectively 00596 */ 00597 CREATE FUNCTION MADLIB_SCHEMA.gamma_quantile( 00598 p DOUBLE PRECISION, 00599 shape DOUBLE PRECISION, 00600 scale DOUBLE PRECISION 00601 ) RETURNS DOUBLE PRECISION 00602 AS 'MODULE_PATHNAME' 00603 LANGUAGE C 00604 IMMUTABLE STRICT; 00605 00606 00607 /** 00608 * @brief Geometric cumulative distribution function 00609 * 00610 * @param x Random variate \f$ x \f$ 00611 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00612 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a geometrically distributed 00613 * random variable with success probability \f$ \mathit{sp} \f$. 00614 */ 00615 CREATE FUNCTION MADLIB_SCHEMA.geometric_cdf( 00616 x DOUBLE PRECISION, 00617 sp DOUBLE PRECISION 00618 ) RETURNS DOUBLE PRECISION 00619 AS 'MODULE_PATHNAME' 00620 LANGUAGE C 00621 IMMUTABLE STRICT; 00622 00623 /** 00624 * @brief Geometric probability mass function 00625 * 00626 * @param x Random variate \f$ x \f$ 00627 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00628 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability mass function of a 00629 * geometrically distributed random variable with success probability 00630 * \f$ \mathit{sp} \f$ 00631 */ 00632 CREATE FUNCTION MADLIB_SCHEMA.geometric_pmf( 00633 x INT4, 00634 sp DOUBLE PRECISION 00635 ) RETURNS DOUBLE PRECISION 00636 AS 'MODULE_PATHNAME' 00637 LANGUAGE C 00638 IMMUTABLE STRICT; 00639 00640 /** 00641 * @brief Geometric quantile function 00642 * 00643 * @param p Probability \f$ p \in [0,1] \f$ 00644 * @param sp Success probability \f$ \mathit{sp} \in [0,1] \f$ 00645 * @return If \f$ p < 0.5 \f$ the maximum \f$ x \f$ such that 00646 * \f$ p \geq \Pr[X \leq x] \f$. If \f$ p \geq 0.5 \f$ the minimum \f$ x \f$ 00647 * such that \f$ p \leq \Pr[X \leq x] \f$. Here, \f$ X \f$ is a 00648 * geometrically distributed random variable with success probability 00649 * \f$ \mathit{sp} \f$. 00650 */ 00651 CREATE FUNCTION MADLIB_SCHEMA.geometric_quantile( 00652 p DOUBLE PRECISION, 00653 sp DOUBLE PRECISION 00654 ) RETURNS DOUBLE PRECISION 00655 AS 'MODULE_PATHNAME' 00656 LANGUAGE C 00657 IMMUTABLE STRICT; 00658 00659 00660 /** 00661 * @brief Hypergeometric cumulative distribution function 00662 * 00663 * @param x Random variate \f$ x \f$ 00664 * @param r Number \f$ r \in \{ 0, 1, \dots, N \} \f$ of items with 00665 * distinct property (sometimes called the number of <em>success states</em> 00666 * in population) 00667 * @param n Number \f$ n \in \{ 0, 1, \dots, N \} \f$ of draws (without 00668 * replacement) 00669 * @param N Total number \f$ N \in \mathbb N \f$ of items 00670 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a hypergeometrically 00671 * distributed random variable with parameters \f$ r, n, N \f$ 00672 * 00673 * @internal Boost error messages refer to parameters 'r', 'n', 'N', so for now 00674 * we use the same identifiers for our function definition. 00675 */ 00676 CREATE FUNCTION MADLIB_SCHEMA.hypergeometric_cdf( 00677 x DOUBLE PRECISION, 00678 r INT4, 00679 n INT4, 00680 "N" INT4 00681 ) RETURNS DOUBLE PRECISION 00682 AS 'MODULE_PATHNAME' 00683 LANGUAGE C 00684 IMMUTABLE STRICT; 00685 00686 /** 00687 * @brief Hypergeometric probability mass function 00688 * 00689 * @param x Random variate \f$ x \f$ 00690 * @param r Number \f$ r \in \{ 0, 1, \dots, N \} \f$ of items with 00691 * distinct property (sometimes called the number of <em>success states</em> 00692 * in population) 00693 * @param n Number \f$ n \in \{ 0, 1, \dots, N \} \f$ of draws (without 00694 * replacement) 00695 * @param N Total number \f$ N \in \mathbb N \f$ of items 00696 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability mass function of 00697 * a hypergeometrically distributed random variable with parameters 00698 * \f$ r, n, N \f$ 00699 */ 00700 CREATE FUNCTION MADLIB_SCHEMA.hypergeometric_pmf( 00701 x INT4, 00702 r INT4, 00703 n INT4, 00704 "N" INT4 00705 ) RETURNS DOUBLE PRECISION 00706 AS 'MODULE_PATHNAME' 00707 LANGUAGE C 00708 IMMUTABLE STRICT; 00709 00710 00711 /** 00712 * @brief Hypergeometric quantile function 00713 * 00714 * @param p Probability \f$ p \in [0,1] \f$ 00715 * @param r Number \f$ r \in \{ 0, 1, \dots, N \} \f$ of items with 00716 * distinct property (sometimes called the number of <em>success states</em> 00717 * in population) 00718 * @param n Number \f$ n \in \{ 0, 1, \dots, N \} \f$ of draws (without 00719 * replacement) 00720 * @param N Total number \f$ N \in \mathbb N \f$ of items 00721 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 00722 * a hypergeometrically distributed random variable with parameters 00723 * \f$ r, n, N \f$ 00724 */ 00725 CREATE FUNCTION MADLIB_SCHEMA.hypergeometric_quantile( 00726 p DOUBLE PRECISION, 00727 r INT4, 00728 n INT4, 00729 "N" INT4 00730 ) RETURNS DOUBLE PRECISION 00731 AS 'MODULE_PATHNAME' 00732 LANGUAGE C 00733 IMMUTABLE STRICT; 00734 00735 00736 /** 00737 * @brief Inverse Gamma cumulative distribution function 00738 * 00739 * @param x Random variate \f$ x \f$ 00740 * @param shape Shape \f$ \alpha > 0 \f$ 00741 * @param scale Scale \f$ \beta > 0 \f$ 00742 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is an inverse-gamma distributed 00743 * random variable with shape and scale parameters \f$ \alpha \f$ and 00744 * \f$ \beta \f$, respectively 00745 */ 00746 CREATE FUNCTION MADLIB_SCHEMA.inverse_gamma_cdf( 00747 x DOUBLE PRECISION, 00748 shape DOUBLE PRECISION, 00749 scale DOUBLE PRECISION 00750 ) RETURNS DOUBLE PRECISION 00751 AS 'MODULE_PATHNAME' 00752 LANGUAGE C 00753 IMMUTABLE STRICT; 00754 00755 /** 00756 * @brief Inverse Gamma probability density function 00757 * 00758 * @param x Random variate \f$ x \f$ 00759 * @param shape Shape \f$ \alpha > 0 \f$ 00760 * @param scale Scale \f$ \beta > 0 \f$ 00761 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00762 * an inverse-gamma distributed random variable with shape and scale 00763 * parameters \f$ \alpha \f$ and \f$ \beta \f$, respectively 00764 */ 00765 CREATE FUNCTION MADLIB_SCHEMA.inverse_gamma_pdf( 00766 x DOUBLE PRECISION, 00767 shape DOUBLE PRECISION, 00768 scale DOUBLE PRECISION 00769 ) RETURNS DOUBLE PRECISION 00770 AS 'MODULE_PATHNAME' 00771 LANGUAGE C 00772 IMMUTABLE STRICT; 00773 00774 /** 00775 * @brief Inverse Gamma quantile function 00776 * 00777 * @param p Probability \f$ p \in [0,1] \f$ 00778 * @param shape Shape \f$ \alpha > 0 \f$ 00779 * @param scale Scale \f$ \beta > 0 \f$ 00780 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 00781 * an inverse-gamma distributed random variable with shape and scale 00782 * parameters \f$ \alpha \f$ and \f$ \beta \f$, respectively 00783 */ 00784 CREATE FUNCTION MADLIB_SCHEMA.inverse_gamma_quantile( 00785 p DOUBLE PRECISION, 00786 shape DOUBLE PRECISION, 00787 scale DOUBLE PRECISION 00788 ) RETURNS DOUBLE PRECISION 00789 AS 'MODULE_PATHNAME' 00790 LANGUAGE C 00791 IMMUTABLE STRICT; 00792 00793 00794 /** 00795 * @brief Kolmogorov cumulative distribution function 00796 * 00797 * @param x Random variate \f$ x \f$ 00798 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Kolmogorov distributed 00799 * random variable 00800 * 00801 * @sa Kolmogorov-Smirnov test: ks_test() 00802 */ 00803 CREATE FUNCTION MADLIB_SCHEMA.kolmogorov_cdf( 00804 x DOUBLE PRECISION 00805 ) RETURNS DOUBLE PRECISION 00806 AS 'MODULE_PATHNAME' 00807 LANGUAGE C 00808 IMMUTABLE STRICT; 00809 00810 00811 /** 00812 * @brief Laplace cumulative distribution function 00813 * 00814 * @param x Random variate \f$ x \f$ 00815 * @param mean Mean \f$ \mu \f$ 00816 * @param scale Scale \f$ b > 0 \f$ 00817 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Laplace-distributed random 00818 * variable with mean \f$ \mu \f$ and variance \f$ 2 b^2 \f$ 00819 */ 00820 CREATE FUNCTION MADLIB_SCHEMA.laplace_cdf( 00821 x DOUBLE PRECISION, 00822 mean DOUBLE PRECISION, 00823 scale DOUBLE PRECISION 00824 ) RETURNS DOUBLE PRECISION 00825 AS 'MODULE_PATHNAME' 00826 LANGUAGE C 00827 IMMUTABLE STRICT; 00828 00829 /** 00830 * @brief Laplace probability density function 00831 * 00832 * @param x Random variate \f$ x \f$ 00833 * @param mean Mean \f$ \mu \f$ 00834 * @param scale Scale \f$ b > 0 \f$ 00835 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00836 * a Laplace-distributed random variable with mean \f$ \mu \f$ and variance 00837 * \f$ 2 b^2 \f$ 00838 */ 00839 CREATE FUNCTION MADLIB_SCHEMA.laplace_pdf( 00840 x DOUBLE PRECISION, 00841 mean DOUBLE PRECISION, 00842 scale DOUBLE PRECISION 00843 ) RETURNS DOUBLE PRECISION 00844 AS 'MODULE_PATHNAME' 00845 LANGUAGE C 00846 IMMUTABLE STRICT; 00847 00848 /** 00849 * @brief Laplace quantile function 00850 * 00851 * @param p Probability \f$ p \in [0,1] \f$ 00852 * @param mean Mean \f$ \mu \f$ 00853 * @param scale Scale \f$ b > 0 \f$ 00854 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 00855 * Laplace-distributed random variable with mean \f$ \mu \f$ and variance 00856 * \f$ 2 b^2 \f$ 00857 */ 00858 CREATE FUNCTION MADLIB_SCHEMA.laplace_quantile( 00859 p DOUBLE PRECISION, 00860 mean DOUBLE PRECISION, 00861 scale DOUBLE PRECISION 00862 ) RETURNS DOUBLE PRECISION 00863 AS 'MODULE_PATHNAME' 00864 LANGUAGE C 00865 IMMUTABLE STRICT; 00866 00867 00868 /** 00869 * @brief Logistic cumulative distribution function 00870 * 00871 * @param x Random variate \f$ x \f$ 00872 * @param mean Mean \f$ \mu \f$ 00873 * @param scale Scale \f$ s > 0 \f$ 00874 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a logistically distributed 00875 * random variable with mean \f$ \mu \f$ and scale parameter \f$ s \f$ 00876 */ 00877 CREATE FUNCTION MADLIB_SCHEMA.logistic_cdf( 00878 x DOUBLE PRECISION, 00879 mean DOUBLE PRECISION, 00880 scale DOUBLE PRECISION 00881 ) RETURNS DOUBLE PRECISION 00882 AS 'MODULE_PATHNAME' 00883 LANGUAGE C 00884 IMMUTABLE STRICT; 00885 00886 /** 00887 * @brief Logistic probability density function 00888 * 00889 * @param x Random variate \f$ x \f$ 00890 * @param mean Mean \f$ \mu \f$ 00891 * @param scale Scale \f$ s > 0 \f$ 00892 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00893 * a logistically distributed random variable with mean \f$ \mu \f$ and 00894 * scale parameter \f$ s \f$ 00895 */ 00896 CREATE FUNCTION MADLIB_SCHEMA.logistic_pdf( 00897 x DOUBLE PRECISION, 00898 mean DOUBLE PRECISION, 00899 scale DOUBLE PRECISION 00900 ) RETURNS DOUBLE PRECISION 00901 AS 'MODULE_PATHNAME' 00902 LANGUAGE C 00903 IMMUTABLE STRICT; 00904 00905 /** 00906 * @brief Logistic quantile function 00907 * 00908 * @param p Probability \f$ p \in [0,1] \f$ 00909 * @param mean Mean \f$ \mu \f$ 00910 * @param scale Scale \f$ s > 0 \f$ 00911 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 00912 * a logistically distributed random variable with mean \f$ \mu \f$ and 00913 * scale parameter \f$ s \f$ 00914 */ 00915 CREATE FUNCTION MADLIB_SCHEMA.logistic_quantile( 00916 p DOUBLE PRECISION, 00917 mean DOUBLE PRECISION, 00918 scale DOUBLE PRECISION 00919 ) RETURNS DOUBLE PRECISION 00920 AS 'MODULE_PATHNAME' 00921 LANGUAGE C 00922 IMMUTABLE STRICT; 00923 00924 00925 /** 00926 * @brief Log-normal cumulative distribution function 00927 * 00928 * @param x Random variate \f$ x \f$ 00929 * @param location Location \f$ m \f$ 00930 * @param scale Scale \f$ s > 0 \f$ 00931 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a lognormally distributed 00932 * random variable with location and scale parameters \f$ m \f$ and 00933 * \f$ s \f$, respectively 00934 */ 00935 CREATE FUNCTION MADLIB_SCHEMA.lognormal_cdf( 00936 x DOUBLE PRECISION, 00937 location DOUBLE PRECISION, 00938 scale DOUBLE PRECISION 00939 ) RETURNS DOUBLE PRECISION 00940 AS 'MODULE_PATHNAME' 00941 LANGUAGE C 00942 IMMUTABLE STRICT; 00943 00944 /** 00945 * @brief Log-normal probability density function 00946 * 00947 * @param x Random variate \f$ x \f$ 00948 * @param location Location \f$ m \f$ 00949 * @param scale Scale \f$ s > 0 \f$ 00950 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 00951 * a lognormally distributed random variable with location and scale 00952 * parameters \f$ m \f$ and \f$ s \f$, respectively 00953 */ 00954 CREATE FUNCTION MADLIB_SCHEMA.lognormal_pdf( 00955 x DOUBLE PRECISION, 00956 location DOUBLE PRECISION, 00957 scale DOUBLE PRECISION 00958 ) RETURNS DOUBLE PRECISION 00959 AS 'MODULE_PATHNAME' 00960 LANGUAGE C 00961 IMMUTABLE STRICT; 00962 00963 /** 00964 * @brief Log-normal quantile function 00965 * 00966 * @param p Probability \f$ p \in [0,1] \f$ 00967 * @param location Location \f$ m \f$ 00968 * @param scale Scale \f$ s > 0 \f$ 00969 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 00970 * a lognormally distributed random variable with location and scale 00971 * parameters \f$ m \f$ and \f$ s \f$, respectively 00972 */ 00973 CREATE FUNCTION MADLIB_SCHEMA.lognormal_quantile( 00974 p DOUBLE PRECISION, 00975 location DOUBLE PRECISION, 00976 scale DOUBLE PRECISION 00977 ) RETURNS DOUBLE PRECISION 00978 AS 'MODULE_PATHNAME' 00979 LANGUAGE C 00980 IMMUTABLE STRICT; 00981 00982 00983 /** 00984 * @brief Negative binomial cumulative distribution function 00985 * 00986 * @param x Random variate \f$ x \f$ 00987 * @param r Total number \f$ r > 0 \f$ of successes in \f$ x + r \f$ trials 00988 * (assuming success in the last trial) 00989 * @param sp Success probability \f$ \mathit{sp} \in (0,1] \f$ in each trial 00990 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a negative-binomially 00991 * distributed random variable with parameters \f$ r, \mathit{sp} \f$ 00992 */ 00993 CREATE FUNCTION MADLIB_SCHEMA.negative_binomial_cdf( 00994 x DOUBLE PRECISION, 00995 r DOUBLE PRECISION, 00996 sp DOUBLE PRECISION 00997 ) RETURNS DOUBLE PRECISION 00998 AS 'MODULE_PATHNAME' 00999 LANGUAGE C 01000 IMMUTABLE STRICT; 01001 01002 /** 01003 * @brief Negative binomial probability mass function 01004 * 01005 * @param x Random variate \f$ x \f$ 01006 * @param r Total number \f$ r > 0 \f$ of successes in \f$ x + r \f$ trials 01007 * (assuming success in the last trial) 01008 * @param sp Success probability \f$ \mathit{sp} \in (0,1] \f$ in each trial 01009 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability mass function of 01010 * a negative-binomially distributed random variable with parameters 01011 * \f$ r, \mathit{sp} \f$ 01012 */ 01013 CREATE FUNCTION MADLIB_SCHEMA.negative_binomial_pmf( 01014 x INT4, 01015 r DOUBLE PRECISION, 01016 sp DOUBLE PRECISION 01017 ) RETURNS DOUBLE PRECISION 01018 AS 'MODULE_PATHNAME' 01019 LANGUAGE C 01020 IMMUTABLE STRICT; 01021 01022 /** 01023 * @brief Negative binomial quantile function 01024 * 01025 * @param p Probability \f$ p \in [0,1] \f$ 01026 * @param r Total number \f$ r > 0 \f$ of successes in \f$ x + r \f$ trials 01027 * (assuming success in the last trial) 01028 * @param sp Success probability \f$ \mathit{sp} \in (0,1] \f$ in each trial 01029 * @return If \f$ p < 0.5 \f$ the maximum \f$ x \f$ such that 01030 * \f$ p \geq \Pr[X \leq x] \f$. If \f$ p \geq 0.5 \f$ the minimum \f$ x \f$ 01031 * such that \f$ p \leq \Pr[X \leq x] \f$. Here, \f$ X \f$ is 01032 * a negative-binomially distributed random variable with parameters 01033 * \f$ r, \mathit{sp} \f$ 01034 */ 01035 CREATE FUNCTION MADLIB_SCHEMA.negative_binomial_quantile( 01036 p DOUBLE PRECISION, 01037 r DOUBLE PRECISION, 01038 sp DOUBLE PRECISION 01039 ) RETURNS DOUBLE PRECISION 01040 AS 'MODULE_PATHNAME' 01041 LANGUAGE C 01042 IMMUTABLE STRICT; 01043 01044 01045 /** 01046 * @brief Noncentral beta cumulative distribution function 01047 * 01048 * @param x Random variate \f$ x \f$ 01049 * @param alpha Shape \f$ \alpha > 0 \f$ 01050 * @param beta Shape \f$ \beta > 0 \f$ 01051 * @param ncp Noncentrality parameter \f$ \delta \geq 0 \f$ 01052 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a noncentral-beta 01053 * distributed random variable with shape parameters \f$ shape_1 \f$ and 01054 * \f$ shape_2 \f$ and noncentrality parameter \f$ \delta \f$ 01055 */ 01056 CREATE FUNCTION MADLIB_SCHEMA.non_central_beta_cdf( 01057 x DOUBLE PRECISION, 01058 alpha DOUBLE PRECISION, 01059 beta DOUBLE PRECISION, 01060 ncp DOUBLE PRECISION 01061 ) RETURNS DOUBLE PRECISION 01062 AS 'MODULE_PATHNAME' 01063 LANGUAGE C 01064 IMMUTABLE STRICT; 01065 01066 /** 01067 * @brief Noncentral beta probability density function 01068 * 01069 * @param x Random variate \f$ x \f$ 01070 * @param alpha Shape \f$ \alpha > 0 \f$ 01071 * @param beta Shape \f$ \beta > 0 \f$ 01072 * @param ncp Noncentrality parameter \f$ \delta \geq 0 \f$ 01073 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01074 * a noncentral-beta distributed random variable with shape parameters 01075 * \f$ shape_1 \f$ and \f$ shape_2 \f$ and noncentrality parameter 01076 * \f$ \delta \f$ 01077 */ 01078 CREATE FUNCTION MADLIB_SCHEMA.non_central_beta_pdf( 01079 x DOUBLE PRECISION, 01080 alpha DOUBLE PRECISION, 01081 beta DOUBLE PRECISION, 01082 ncp DOUBLE PRECISION 01083 ) RETURNS DOUBLE PRECISION 01084 AS 'MODULE_PATHNAME' 01085 LANGUAGE C 01086 IMMUTABLE STRICT; 01087 01088 /** 01089 * @brief Noncentral beta quantile function 01090 * 01091 * @param p Probability \f$ p \in [0,1] \f$ 01092 * @param alpha Shape \f$ \alpha > 0 \f$ 01093 * @param beta Shape \f$ \beta > 0 \f$ 01094 * @param ncp Noncentrality parameter \f$ \delta \geq 0 \f$ 01095 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is 01096 * a noncentral-beta distributed random variable with shape parameters 01097 * \f$ shape_1 \f$ and \f$ shape_2 \f$ and noncentrality parameter 01098 * \f$ \delta \f$ 01099 */ 01100 CREATE FUNCTION MADLIB_SCHEMA.non_central_beta_quantile( 01101 p DOUBLE PRECISION, 01102 alpha DOUBLE PRECISION, 01103 beta DOUBLE PRECISION, 01104 ncp DOUBLE PRECISION 01105 ) RETURNS DOUBLE PRECISION 01106 AS 'MODULE_PATHNAME' 01107 LANGUAGE C 01108 IMMUTABLE STRICT; 01109 01110 01111 /** 01112 * @brief Noncentral chi-squared cumulative distribution function 01113 * 01114 * @param x Random variate \f$ x \f$ 01115 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01116 * @param ncp The noncentrality parameter \f$ \lambda \geq 0 \f$ 01117 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a noncentral-chi-squared 01118 * distributed random variable with \f$ \nu \f$ degrees of freedom and 01119 * noncentrality parameter \f$ \lambda \f$ 01120 */ 01121 CREATE FUNCTION MADLIB_SCHEMA.non_central_chi_squared_cdf( 01122 x DOUBLE PRECISION, 01123 df DOUBLE PRECISION, 01124 ncp DOUBLE PRECISION 01125 ) RETURNS DOUBLE PRECISION 01126 AS 'MODULE_PATHNAME' 01127 LANGUAGE C 01128 IMMUTABLE STRICT; 01129 01130 /** 01131 * @brief Noncentral chi-squared distribution probability density function 01132 * 01133 * @param x Random variate \f$ x \f$ 01134 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01135 * @param ncp The noncentrality parameter \f$ \lambda \geq 0 \f$ 01136 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01137 * a noncentral-chi-squared distributed random variable with \f$ \nu \f$ 01138 * degrees of freedom and noncentrality parameter \f$ \lambda \f$ 01139 */ 01140 CREATE FUNCTION MADLIB_SCHEMA.non_central_chi_squared_pdf( 01141 x DOUBLE PRECISION, 01142 df DOUBLE PRECISION, 01143 ncp DOUBLE PRECISION 01144 ) RETURNS DOUBLE PRECISION 01145 AS 'MODULE_PATHNAME' 01146 LANGUAGE C 01147 IMMUTABLE STRICT; 01148 01149 /** 01150 * @brief Noncentral chi-squared distribution quantile function 01151 * 01152 * @param p Probability \f$ p \in [0,1] \f$ 01153 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01154 * @param ncp The noncentrality parameter \f$ \lambda \geq 0 \f$ 01155 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01156 * noncentral-chi-squared distributed random variable with \f$ \nu \f$ 01157 * degrees of freedom and noncentrality parameter \f$ \lambda \f$ 01158 */ 01159 CREATE FUNCTION MADLIB_SCHEMA.non_central_chi_squared_quantile( 01160 p DOUBLE PRECISION, 01161 df DOUBLE PRECISION, 01162 ncp DOUBLE PRECISION 01163 ) RETURNS DOUBLE PRECISION 01164 AS 'MODULE_PATHNAME' 01165 LANGUAGE C 01166 IMMUTABLE STRICT; 01167 01168 01169 /** 01170 * @brief Noncentral Fisher F cumulative distribution function 01171 * 01172 * @param x Random variate \f$ x \f$ 01173 * @param df1 Degrees of freedom in numerator \f$ \nu_1 > 0 \f$ 01174 * @param df2 Degrees of freedom in denominator \f$ \nu_1 > 0 \f$ 01175 * @param ncp The noncentrality parameter \f$ \lambda \geq 0 \f$ 01176 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a 01177 * noncentral Fisher F-distributed random variable with parameters 01178 * \f$ \nu_1, \nu_2, \lambda \f$ 01179 */ 01180 CREATE FUNCTION MADLIB_SCHEMA.non_central_f_cdf( 01181 x DOUBLE PRECISION, 01182 df1 DOUBLE PRECISION, 01183 df2 DOUBLE PRECISION, 01184 ncp DOUBLE PRECISION 01185 ) RETURNS DOUBLE PRECISION 01186 AS 'MODULE_PATHNAME' 01187 LANGUAGE C 01188 IMMUTABLE STRICT; 01189 01190 /** 01191 * @brief Noncentral Fisher F probability density function 01192 * 01193 * @param x Random variate \f$ x \f$ 01194 * @param df1 Degrees of freedom in numerator \f$ \nu_1 > 0 \f$ 01195 * @param df2 Degrees of freedom in denominator \f$ \nu_1 > 0 \f$ 01196 * @param ncp The noncentrality parameter \f$ \lambda \geq 0 \f$ 01197 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of a 01198 * noncentral Fisher F-distributed random variable with parameters 01199 * \f$ \nu_1, \nu_2, \lambda \f$ 01200 */ 01201 CREATE FUNCTION MADLIB_SCHEMA.non_central_f_pdf( 01202 x DOUBLE PRECISION, 01203 df1 DOUBLE PRECISION, 01204 df2 DOUBLE PRECISION, 01205 ncp DOUBLE PRECISION 01206 ) RETURNS DOUBLE PRECISION 01207 AS 'MODULE_PATHNAME' 01208 LANGUAGE C 01209 IMMUTABLE STRICT; 01210 01211 /** 01212 * @brief Noncentral Fisher F quantile function 01213 * 01214 * @param p Probability \f$ p \in [0,1] \f$ 01215 * @param df1 Degrees of freedom in numerator \f$ \nu_1 > 0 \f$ 01216 * @param df2 Degrees of freedom in denominator \f$ \nu_1 > 0 \f$ 01217 * @param ncp The noncentrality parameter \f$ \lambda \geq 0 \f$ 01218 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01219 * noncentral Fisher F-distributed random variable with parameters 01220 * \f$ \nu_1, \nu_2, \lambda \f$ 01221 */ 01222 CREATE FUNCTION MADLIB_SCHEMA.non_central_f_quantile( 01223 p DOUBLE PRECISION, 01224 df1 DOUBLE PRECISION, 01225 df2 DOUBLE PRECISION, 01226 ncp DOUBLE PRECISION 01227 ) RETURNS DOUBLE PRECISION 01228 AS 'MODULE_PATHNAME' 01229 LANGUAGE C 01230 IMMUTABLE STRICT; 01231 01232 01233 /** 01234 * @brief Noncentral Student-t cumulative distribution function 01235 * 01236 * @param x Random variate \f$ x \f$ 01237 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01238 * @param ncp Noncentrality parameter \f$ \delta \f$ 01239 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a noncentral Student's 01240 * t-distributed random variable with \f$ \nu \f$ degrees of freedom and 01241 * noncentrality parameter \f$ \delta \f$ 01242 */ 01243 CREATE FUNCTION MADLIB_SCHEMA.non_central_t_cdf( 01244 x DOUBLE PRECISION, 01245 df DOUBLE PRECISION, 01246 ncp DOUBLE PRECISION 01247 ) RETURNS DOUBLE PRECISION 01248 AS 'MODULE_PATHNAME' 01249 LANGUAGE C 01250 IMMUTABLE STRICT; 01251 01252 /** 01253 * @brief Noncentral Student-t probability density function 01254 * 01255 * @param x Random variate \f$ x \f$ 01256 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01257 * @param ncp Noncentrality parameter \f$ \delta \f$ 01258 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01259 * noncentral Student's t-distributed random variable with \f$ \nu \f$ 01260 * degrees of freedom and noncentrality parameter \f$ \delta \f$ 01261 */ 01262 CREATE FUNCTION MADLIB_SCHEMA.non_central_t_pdf( 01263 x DOUBLE PRECISION, 01264 df DOUBLE PRECISION, 01265 ncp DOUBLE PRECISION 01266 ) RETURNS DOUBLE PRECISION 01267 AS 'MODULE_PATHNAME' 01268 LANGUAGE C 01269 IMMUTABLE STRICT; 01270 01271 /** 01272 * @brief Noncentral Student-t quantile function 01273 * 01274 * @param p Probability \f$ p \in [0,1] \f$ 01275 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01276 * @param ncp Noncentrality parameter \f$ \delta \f$ 01277 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01278 * noncentral Student's t-distributed random variable with \f$ \nu \f$ 01279 * degrees of freedom and noncentrality parameter \f$ \delta \f$ 01280 */ 01281 CREATE FUNCTION MADLIB_SCHEMA.non_central_t_quantile( 01282 p DOUBLE PRECISION, 01283 df DOUBLE PRECISION, 01284 ncp DOUBLE PRECISION 01285 ) RETURNS DOUBLE PRECISION 01286 AS 'MODULE_PATHNAME' 01287 LANGUAGE C 01288 IMMUTABLE STRICT; 01289 01290 01291 /** 01292 * @brief Normal cumulative distribution function 01293 * 01294 * @param x Random variate \f$ x \f$ 01295 * @param mean Mean \f$ \mu \f$ 01296 * @param sd Standard deviation \f$ \sigma > 0 \f$ 01297 * @return \f$ \Pr[X \leq x] \f$ where \f$ T \f$ is a normally distributed 01298 * random variable with mean \f$ \mu \f$ and variance \f$ \sigma^2 \f$ 01299 */ 01300 CREATE FUNCTION MADLIB_SCHEMA.normal_cdf( 01301 x DOUBLE PRECISION, 01302 mean DOUBLE PRECISION /*+ DEFAULT 0 */, 01303 sd DOUBLE PRECISION /*+ DEFAULT 1 */ 01304 ) RETURNS DOUBLE PRECISION 01305 AS 'MODULE_PATHNAME' 01306 LANGUAGE C 01307 IMMUTABLE STRICT; 01308 01309 CREATE FUNCTION MADLIB_SCHEMA.normal_cdf( 01310 x DOUBLE PRECISION, 01311 mean DOUBLE PRECISION 01312 ) RETURNS DOUBLE PRECISION 01313 IMMUTABLE 01314 STRICT 01315 LANGUAGE sql AS $$ 01316 SELECT MADLIB_SCHEMA.normal_cdf($1, $2, 1) 01317 $$; 01318 01319 CREATE FUNCTION MADLIB_SCHEMA.normal_cdf( 01320 x DOUBLE PRECISION 01321 ) RETURNS DOUBLE PRECISION 01322 IMMUTABLE 01323 STRICT 01324 LANGUAGE sql AS $$ 01325 SELECT MADLIB_SCHEMA.normal_cdf($1, 0, 1) 01326 $$; 01327 01328 /** 01329 * @brief Normal probability density function 01330 * 01331 * @param x Random variate \f$ x \f$ 01332 * @param mean Mean \f$ \mu \f$ 01333 * @param sd Standard deviation \f$ \sigma > 0 \f$ 01334 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01335 * a normally distributed random variable with mean \f$ \mu \f$ and 01336 * variance \f$ \sigma^2 \f$ 01337 */ 01338 CREATE FUNCTION MADLIB_SCHEMA.normal_pdf( 01339 x DOUBLE PRECISION, 01340 mean DOUBLE PRECISION /*+ DEFAULT 0 */, 01341 sd DOUBLE PRECISION /*+ DEFAULT 1 */ 01342 ) RETURNS DOUBLE PRECISION 01343 AS 'MODULE_PATHNAME' 01344 LANGUAGE C 01345 IMMUTABLE STRICT; 01346 01347 CREATE FUNCTION MADLIB_SCHEMA.normal_pdf( 01348 x DOUBLE PRECISION, 01349 mean DOUBLE PRECISION 01350 ) RETURNS DOUBLE PRECISION 01351 IMMUTABLE 01352 STRICT 01353 LANGUAGE sql AS $$ 01354 SELECT MADLIB_SCHEMA.normal_pdf($1, $2, 1) 01355 $$; 01356 01357 CREATE FUNCTION MADLIB_SCHEMA.normal_pdf( 01358 x DOUBLE PRECISION 01359 ) RETURNS DOUBLE PRECISION 01360 IMMUTABLE 01361 STRICT 01362 LANGUAGE sql AS $$ 01363 SELECT MADLIB_SCHEMA.normal_pdf($1, 0, 1) 01364 $$; 01365 01366 /** 01367 * @brief Normal quantile function 01368 * 01369 * @param p Probability \f$ p \in [0,1] \f$ 01370 * @param mean Mean \f$ \mu \f$ 01371 * @param sd Standard deviation \f$ \sigma > 0 \f$ 01372 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01373 * normally distributed random variable with mean \f$ \mu \f$ and 01374 * variance \f$ \sigma^2 \f$ 01375 */ 01376 CREATE FUNCTION MADLIB_SCHEMA.normal_quantile( 01377 p DOUBLE PRECISION, 01378 mean DOUBLE PRECISION /*+ DEFAULT 0 */, 01379 sd DOUBLE PRECISION /*+ DEFAULT 1 */ 01380 ) RETURNS DOUBLE PRECISION 01381 AS 'MODULE_PATHNAME' 01382 LANGUAGE C 01383 IMMUTABLE STRICT; 01384 01385 CREATE FUNCTION MADLIB_SCHEMA.normal_quantile( 01386 p DOUBLE PRECISION, 01387 mean DOUBLE PRECISION 01388 ) RETURNS DOUBLE PRECISION 01389 IMMUTABLE 01390 STRICT 01391 LANGUAGE sql AS $$ 01392 SELECT MADLIB_SCHEMA.normal_quantile($1, $2, 1) 01393 $$; 01394 01395 CREATE FUNCTION MADLIB_SCHEMA.normal_quantile( 01396 p DOUBLE PRECISION 01397 ) RETURNS DOUBLE PRECISION 01398 IMMUTABLE 01399 STRICT 01400 LANGUAGE sql AS $$ 01401 SELECT MADLIB_SCHEMA.normal_quantile($1, 0, 1) 01402 $$; 01403 01404 01405 /** 01406 * @brief Pareto cumulative distribution function 01407 * 01408 * @param x Random variate \f$ x \f$ 01409 * @param scale Scale \f$ \beta > 0 \f$ 01410 * @param shape Shape \f$ \alpha > 0 \f$ 01411 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Pareto-distributed random 01412 * variable with shape and scale parameters \f$ \alpha \f$ and 01413 * \f$ \beta \f$, respectively 01414 */ 01415 CREATE FUNCTION MADLIB_SCHEMA.pareto_cdf( 01416 x DOUBLE PRECISION, 01417 scale DOUBLE PRECISION, 01418 shape DOUBLE PRECISION 01419 ) RETURNS DOUBLE PRECISION 01420 AS 'MODULE_PATHNAME' 01421 LANGUAGE C 01422 IMMUTABLE STRICT; 01423 01424 /** 01425 * @brief Pareto probability density function 01426 * 01427 * @param x Random variate \f$ x \f$ 01428 * @param scale Scale \f$ \beta > 0 \f$ 01429 * @param shape Shape \f$ \alpha > 0 \f$ 01430 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01431 * a Pareto-distributed random variable with shape and scale parameters 01432 * \f$ \alpha \f$ and \f$ \beta \f$, respectively 01433 */ 01434 CREATE FUNCTION MADLIB_SCHEMA.pareto_pdf( 01435 x DOUBLE PRECISION, 01436 scale DOUBLE PRECISION, 01437 shape DOUBLE PRECISION 01438 ) RETURNS DOUBLE PRECISION 01439 AS 'MODULE_PATHNAME' 01440 LANGUAGE C 01441 IMMUTABLE STRICT; 01442 01443 /** 01444 * @brief Pareto quantile function 01445 * 01446 * @param p Probability \f$ p \in [0,1] \f$ 01447 * @param scale Scale \f$ \beta > 0 \f$ 01448 * @param shape Shape \f$ \alpha > 0 \f$ 01449 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01450 * Pareto-distributed random variable with shape and scale parameters 01451 * \f$ \alpha \f$ and \f$ \beta \f$, respectively 01452 */ 01453 CREATE FUNCTION MADLIB_SCHEMA.pareto_quantile( 01454 p DOUBLE PRECISION, 01455 scale DOUBLE PRECISION, 01456 shape DOUBLE PRECISION 01457 ) RETURNS DOUBLE PRECISION 01458 AS 'MODULE_PATHNAME' 01459 LANGUAGE C 01460 IMMUTABLE STRICT; 01461 01462 01463 /** 01464 * @brief Poisson cumulative distribution function 01465 * 01466 * @param x Random variate \f$ x \f$ 01467 * @param mean Average occurrence rate \f$ \lambda > 0 \f$ 01468 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Poisson distributed random 01469 * variable with mean \f$ \lambda \f$ 01470 */ 01471 CREATE FUNCTION MADLIB_SCHEMA.poisson_cdf( 01472 x DOUBLE PRECISION, 01473 mean DOUBLE PRECISION 01474 ) RETURNS DOUBLE PRECISION 01475 AS 'MODULE_PATHNAME' 01476 LANGUAGE C 01477 IMMUTABLE STRICT; 01478 01479 /** 01480 * @brief Poisson probability mass function 01481 * 01482 * @param x Random variate \f$ x \f$ 01483 * @param mean Average occurrence rate \f$ \lambda > 0 \f$ 01484 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability mass function of a 01485 * Poisson distributed random variable with mean \f$ \lambda \f$ 01486 */ 01487 CREATE FUNCTION MADLIB_SCHEMA.poisson_pmf( 01488 x INT4, 01489 mean DOUBLE PRECISION 01490 ) RETURNS DOUBLE PRECISION 01491 AS 'MODULE_PATHNAME' 01492 LANGUAGE C 01493 IMMUTABLE STRICT; 01494 01495 /** 01496 * @brief Poisson quantile function 01497 * 01498 * @param p Probability \f$ p \in [0,1] \f$ 01499 * @param mean Average occurrence rate \f$ \lambda > 0 \f$ 01500 * @return If \f$ p < 0.5 \f$ the maximum \f$ x \f$ such that 01501 * \f$ p \geq \Pr[X \leq x] \f$. If \f$ p \geq 0.5 \f$ the minimum \f$ x \f$ 01502 * such that \f$ p \leq \Pr[X \leq x] \f$. Here, \f$ X \f$ is a 01503 * Poisson distributed random variable with mean \f$ \lambda \f$ 01504 */ 01505 CREATE FUNCTION MADLIB_SCHEMA.poisson_quantile( 01506 p DOUBLE PRECISION, 01507 mean DOUBLE PRECISION 01508 ) RETURNS DOUBLE PRECISION 01509 AS 'MODULE_PATHNAME' 01510 LANGUAGE C 01511 IMMUTABLE STRICT; 01512 01513 01514 /** 01515 * @brief Rayleigh cumulative distribution function 01516 * 01517 * @param x Random variate \f$ x \f$ 01518 * @param scale Scale \f$ \sigma > 0 \f$ 01519 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Rayleigh-distributed 01520 * random variable with parameter \f$ \sigma \f$ 01521 */ 01522 CREATE FUNCTION MADLIB_SCHEMA.rayleigh_cdf( 01523 x DOUBLE PRECISION, 01524 scale DOUBLE PRECISION 01525 ) RETURNS DOUBLE PRECISION 01526 AS 'MODULE_PATHNAME' 01527 LANGUAGE C 01528 IMMUTABLE STRICT; 01529 01530 /** 01531 * @brief Rayleigh probability density function 01532 * 01533 * @param x Random variate \f$ x \f$ 01534 * @param scale Scale \f$ \sigma > 0 \f$ 01535 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01536 * a Rayleigh-distributed random variable with parameter \f$ \sigma \f$ 01537 */ 01538 CREATE FUNCTION MADLIB_SCHEMA.rayleigh_pdf( 01539 x DOUBLE PRECISION, 01540 scale DOUBLE PRECISION 01541 ) RETURNS DOUBLE PRECISION 01542 AS 'MODULE_PATHNAME' 01543 LANGUAGE C 01544 IMMUTABLE STRICT; 01545 01546 /** 01547 * @brief Rayleigh quantile function 01548 * 01549 * @param p Probability \f$ p \in [0,1] \f$ 01550 * @param scale Scale \f$ \sigma > 0 \f$ 01551 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01552 * Rayleigh-distributed random variable with parameter \f$ \sigma \f$ 01553 */ 01554 CREATE FUNCTION MADLIB_SCHEMA.rayleigh_quantile( 01555 p DOUBLE PRECISION, 01556 scale DOUBLE PRECISION 01557 ) RETURNS DOUBLE PRECISION 01558 AS 'MODULE_PATHNAME' 01559 LANGUAGE C 01560 IMMUTABLE STRICT; 01561 01562 01563 /** 01564 * @brief Student's t cumulative distribution function 01565 * 01566 * @param x Random variate \f$ x \f$ 01567 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01568 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a Student's t-distributed 01569 * random variable with \f$ \nu \f$ degrees of freedom 01570 */ 01571 CREATE FUNCTION MADLIB_SCHEMA.students_t_cdf( 01572 x DOUBLE PRECISION, 01573 df DOUBLE PRECISION 01574 ) RETURNS DOUBLE PRECISION 01575 AS 'MODULE_PATHNAME' 01576 LANGUAGE C 01577 IMMUTABLE STRICT; 01578 01579 /** 01580 * @brief Student's t probability density function 01581 * 01582 * @param x Random variate \f$ x \f$ 01583 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01584 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01585 * a Stundent's t-distributed random variable with \f$ \nu \f$ degrees of 01586 * freedom 01587 */ 01588 CREATE FUNCTION MADLIB_SCHEMA.students_t_pdf( 01589 x DOUBLE PRECISION, 01590 df DOUBLE PRECISION 01591 ) RETURNS DOUBLE PRECISION 01592 AS 'MODULE_PATHNAME' 01593 LANGUAGE C 01594 IMMUTABLE STRICT; 01595 01596 /** 01597 * @brief Student's t quantile function 01598 * 01599 * @param p Probability \f$ p \in [0,1] \f$ 01600 * @param df Degrees of freedom \f$ \nu > 0 \f$ 01601 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01602 * Student's t-distributed random variable with \f$ \nu \f$ degrees of 01603 * freedom 01604 */ 01605 CREATE FUNCTION MADLIB_SCHEMA.students_t_quantile( 01606 p DOUBLE PRECISION, 01607 df DOUBLE PRECISION 01608 ) RETURNS DOUBLE PRECISION 01609 AS 'MODULE_PATHNAME' 01610 LANGUAGE C 01611 IMMUTABLE STRICT; 01612 01613 01614 /** 01615 * @brief Triangular cumulative distribution function 01616 * 01617 * @param x Random variate \f$ x \f$ 01618 * @param lower Lower bound \f$ a \f$ 01619 * @param mode Mode \f$ c \geq a \f$ 01620 * @param upper Upper bound \f$ b \geq c \f$, where \f$ b > a \f$ 01621 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a triangular distributed 01622 * random variable with parameters \f$ a, b, c \f$ 01623 */ 01624 CREATE FUNCTION MADLIB_SCHEMA.triangular_cdf( 01625 x DOUBLE PRECISION, 01626 lower DOUBLE PRECISION, 01627 mode DOUBLE PRECISION, 01628 upper DOUBLE PRECISION 01629 ) RETURNS DOUBLE PRECISION 01630 AS 'MODULE_PATHNAME' 01631 LANGUAGE C 01632 IMMUTABLE STRICT; 01633 01634 /** 01635 * @brief Triangular probability density function 01636 * 01637 * @param x Random variate \f$ x \f$ 01638 * @param lower Lower bound \f$ a \f$ 01639 * @param mode Mode \f$ c \geq a \f$ 01640 * @param upper Upper bound \f$ b \geq c \f$, where \f$ b > a \f$ 01641 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01642 * a triangular distributed random variable with parameters \f$ a, b, c \f$ 01643 */ 01644 CREATE FUNCTION MADLIB_SCHEMA.triangular_pdf( 01645 x DOUBLE PRECISION, 01646 lower DOUBLE PRECISION, 01647 mode DOUBLE PRECISION, 01648 upper DOUBLE PRECISION 01649 ) RETURNS DOUBLE PRECISION 01650 AS 'MODULE_PATHNAME' 01651 LANGUAGE C 01652 IMMUTABLE STRICT; 01653 01654 /** 01655 * @brief Triangular quantile function 01656 * 01657 * @param p Probability \f$ p \in [0,1] \f$ 01658 * @param lower Lower bound \f$ a \f$ 01659 * @param mode Mode \f$ c \geq a \f$ 01660 * @param upper Upper bound \f$ b \geq c \f$, where \f$ b > a \f$ 01661 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01662 * trianbular distributed random variable with parameters \f$ a, b, c \f$ 01663 */ 01664 CREATE FUNCTION MADLIB_SCHEMA.triangular_quantile( 01665 p DOUBLE PRECISION, 01666 lower DOUBLE PRECISION, 01667 mode DOUBLE PRECISION, 01668 upper DOUBLE PRECISION 01669 ) RETURNS DOUBLE PRECISION 01670 AS 'MODULE_PATHNAME' 01671 LANGUAGE C 01672 IMMUTABLE STRICT; 01673 01674 01675 /** 01676 * @brief Uniform cumulative distribution function 01677 * 01678 * @param x Random variate \f$ x \f$ 01679 * @param lower Lower bound \f$ a \f$ 01680 * @param upper Upper bound \f$ b \f$ 01681 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a uniform distributed random 01682 * variable with support \f$ [a, b] \f$ 01683 */ 01684 CREATE FUNCTION MADLIB_SCHEMA.uniform_cdf( 01685 x DOUBLE PRECISION, 01686 lower DOUBLE PRECISION, 01687 upper DOUBLE PRECISION 01688 ) RETURNS DOUBLE PRECISION 01689 AS 'MODULE_PATHNAME' 01690 LANGUAGE C 01691 IMMUTABLE STRICT; 01692 01693 /** 01694 * @brief Uniform probability density function 01695 * 01696 * @param x Random variate \f$ x \f$ 01697 * @param lower Lower bound \f$ a \f$ 01698 * @param upper Upper bound \f$ b \f$ 01699 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01700 * a uniform distributed random variable with support \f$ [a, b] \f$ 01701 */ 01702 CREATE FUNCTION MADLIB_SCHEMA.uniform_pdf( 01703 x DOUBLE PRECISION, 01704 lower DOUBLE PRECISION, 01705 upper DOUBLE PRECISION 01706 ) RETURNS DOUBLE PRECISION 01707 AS 'MODULE_PATHNAME' 01708 LANGUAGE C 01709 IMMUTABLE STRICT; 01710 01711 /** 01712 * @brief Uniform quantile function 01713 * 01714 * @param p Probability \f$ p \in [0,1] \f$ 01715 * @param lower Lower bound \f$ a \f$ 01716 * @param upper Upper bound \f$ b \f$ 01717 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01718 * uniform distributed random variable with support \f$ [a, b] \f$ 01719 */ 01720 CREATE FUNCTION MADLIB_SCHEMA.uniform_quantile( 01721 p DOUBLE PRECISION, 01722 lower DOUBLE PRECISION, 01723 upper DOUBLE PRECISION 01724 ) RETURNS DOUBLE PRECISION 01725 AS 'MODULE_PATHNAME' 01726 LANGUAGE C 01727 IMMUTABLE STRICT; 01728 01729 01730 /** 01731 * @brief Weibull cumulative distribution function 01732 * 01733 * @param x Random variate \f$ x \f$ 01734 * @param shape Shape \f$ \alpha > 0 \f$ 01735 * @param scale Scale \f$ \beta > 0 \f$ 01736 * @return \f$ \Pr[X \leq x] \f$ where \f$ X \f$ is a weibull distributed random 01737 * variable with shape and scale parameters \f$ \alpha \f$ and 01738 * \f$ \beta \f$, respectively 01739 */ 01740 CREATE FUNCTION MADLIB_SCHEMA.weibull_cdf( 01741 x DOUBLE PRECISION, 01742 shape DOUBLE PRECISION, 01743 scale DOUBLE PRECISION 01744 ) RETURNS DOUBLE PRECISION 01745 AS 'MODULE_PATHNAME' 01746 LANGUAGE C 01747 IMMUTABLE STRICT; 01748 01749 /** 01750 * @brief Weibull probability density function 01751 * 01752 * @param x Random variate \f$ x \f$ 01753 * @param shape Shape \f$ \alpha > 0 \f$ 01754 * @param scale Scale \f$ \beta > 0 \f$ 01755 * @return \f$ f(x) \f$ where \f$ f \f$ is the probability density function of 01756 * a weibull distributed random variable with shape and scale parameters 01757 * \f$ \alpha \f$ and \f$ \beta \f$, respectively 01758 */ 01759 CREATE FUNCTION MADLIB_SCHEMA.weibull_pdf( 01760 x DOUBLE PRECISION, 01761 shape DOUBLE PRECISION, 01762 scale DOUBLE PRECISION 01763 ) RETURNS DOUBLE PRECISION 01764 AS 'MODULE_PATHNAME' 01765 LANGUAGE C 01766 IMMUTABLE STRICT; 01767 01768 /** 01769 * @brief Weibull quantile function 01770 * 01771 * @param p Probability \f$ p \in [0,1] \f$ 01772 * @param shape Shape \f$ \alpha > 0 \f$ 01773 * @param scale Scale \f$ \beta > 0 \f$ 01774 * @return \f$ x \f$ such that \f$ p = \Pr[X \leq x] \f$ where \f$ X \f$ is a 01775 * weibull distributed random variable with shape and scale parameters 01776 * \f$ \alpha \f$ and \f$ \beta \f$, respectively 01777 */ 01778 CREATE FUNCTION MADLIB_SCHEMA.weibull_quantile( 01779 p DOUBLE PRECISION, 01780 shape DOUBLE PRECISION, 01781 scale DOUBLE PRECISION 01782 ) RETURNS DOUBLE PRECISION 01783 AS 'MODULE_PATHNAME' 01784 LANGUAGE C 01785 IMMUTABLE STRICT;