/* ndtril.c
*
* Inverse of Normal distribution function
*
*
*
* SYNOPSIS :
*
* long double x , y , ndtril ( ) ;
*
* x = ndtril ( y ) ;
*
*
*
* DESCRIPTION :
*
* Returns the argument , x , for which the area under the
* Gaussian probability density function ( integrated from
* minus infinity to x ) is equal to y .
*
*
* For small arguments 0 < y < exp ( - 2 ) , the program computes
* z = sqrt ( - 2 log ( y ) ) ; then the approximation is
* x = z - log ( z ) / z - ( 1 / z ) P ( 1 / z ) / Q ( 1 / z ) .
* For larger arguments , x / sqrt ( 2 pi ) = w + w ^ 3 R ( w ^ 2 ) / S ( w ^ 2 ) ) ,
* where w = y - 0 . 5 .
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* Arguments uniformly distributed :
* IEEE 0 , 1 5000 7 . 8 e - 19 9 . 9 e - 20
* Arguments exponentially distributed :
* IEEE exp ( - 11355 ) , - 1 30000 1 . 7 e - 19 4 . 3 e - 20
*
*
* ERROR MESSAGES :
*
* message condition value returned
* ndtril domain x < = 0 - MAXNUML
* ndtril domain x > = 1 MAXNUML
*
*/
/*
Cephes Math Library Release 2 . 3 : January , 1995
Copyright 1984 , 1995 by Stephen L . Moshier
*/
#include "mconf.h"
extern long double MAXNUML;
/* ndtri(y+0.5)/sqrt(2 pi) = y + y^3 R(y^2)
0 < = y < = 3 / 8
Peak relative error 6.8e-21. */
#if UNK
/* sqrt(2pi) */
static long double s2pi = 2 .506628274631000502416 E0L;
static long double P0[8 ] = {
8 .779679420055069160496 E-3 L,
-7 .649544967784380691785 E-1 L,
2 .971493676711545292135 E0L,
-4 .144980036933753828858 E0L,
2 .765359913000830285937 E0L,
-9 .570456817794268907847 E-1 L,
1 .659219375097958322098 E-1 L,
-1 .140013969885358273307 E-2 L,
};
static long double Q0[7 ] = {
/* 1.000000000000000000000E0L, */
-5 .303846964603721860329 E0L,
9 .908875375256718220854 E0L,
-9 .031318655459381388888 E0L,
4 .496118508523213950686 E0L,
-1 .250016921424819972516 E0L,
1 .823840725000038842075 E-1 L,
-1 .088633151006419263153 E-2 L,
};
#endif
#if IBMPC
static unsigned short s2p[] = {
0 x2cb3,0 xb138,0 x98ff,0 xa06c,0 x4000, XPD
};
#define s2pi *(long double *)s2p
static short P0[] = {
0 xb006,0 x9fc1,0 xa4fe,0 x8fd8,0 x3ff8, XPD
0 x6f8a,0 x976e,0 x0ed2,0 xc3d4,0 xbffe, XPD
0 xf1f1,0 x6fcc,0 xf3d0,0 xbe2c,0 x4000, XPD
0 xccfb,0 xa681,0 xad2c,0 x84a3,0 xc001, XPD
0 x9a0d,0 x0082,0 xa825,0 xb0fb,0 x4000, XPD
0 x13d1,0 x054a,0 xf220,0 xf500,0 xbffe, XPD
0 xcee9,0 x2c92,0 x70bd,0 xa9e7,0 x3ffc, XPD
0 x5fee,0 x4a42,0 xa6cb,0 xbac7,0 xbff8, XPD
};
static short Q0[] = {
/* 0x0000,0x0000,0x0000,0x8000,0x3fff, XPD */
0 x841e,0 xfec7,0 x1d44,0 xa9b9,0 xc001, XPD
0 x97e6,0 xcde0,0 xc0e7,0 x9e8a,0 x4002, XPD
0 x66f9,0 x8f3e,0 x47fd,0 x9080,0 xc002, XPD
0 x212f,0 x2185,0 x33ec,0 x8fe0,0 x4001, XPD
0 x8e73,0 x7bac,0 x8df2,0 xa000,0 xbfff, XPD
0 xc143,0 xcb94,0 xe3ea,0 xbac2,0 x3ffc, XPD
0 x25d9,0 xc8f3,0 x9573,0 xb25c,0 xbff8, XPD
};
#endif
#if MIEEE
static unsigned long s2p[] = {
0 x40000000,0 xa06c98ff,0 xb1382cb3,
};
#define s2pi *(long double *)s2p
static long P0[24 ] = {
0 x3ff80000,0 x8fd8a4fe,0 x9fc1b006,
0 xbffe0000,0 xc3d40ed2,0 x976e6f8a,
0 x40000000,0 xbe2cf3d0,0 x6fccf1f1,
0 xc0010000,0 x84a3ad2c,0 xa681ccfb,
0 x40000000,0 xb0fba825,0 x00829a0d,
0 xbffe0000,0 xf500f220,0 x054a13d1,
0 x3ffc0000,0 xa9e770bd,0 x2c92cee9,
0 xbff80000,0 xbac7a6cb,0 x4a425fee,
};
static long Q0[21 ] = {
/* 0x3fff0000,0x80000000,0x00000000, */
0 xc0010000,0 xa9b91d44,0 xfec7841e,
0 x40020000,0 x9e8ac0e7,0 xcde097e6,
0 xc0020000,0 x908047fd,0 x8f3e66f9,
0 x40010000,0 x8fe033ec,0 x2185212f,
0 xbfff0000,0 xa0008df2,0 x7bac8e73,
0 x3ffc0000,0 xbac2e3ea,0 xcb94c143,
0 xbff80000,0 xb25c9573,0 xc8f325d9,
};
#endif
/* Approximation for interval z = sqrt(-2 log y ) between 2 and 8
*/
/* ndtri(p) = z - ln(z)/z - 1/z P1(1/z)/Q1(1/z)
z = sqrt ( - 2 ln ( p ) )
2 < = z < = 8 , i . e . , y between exp ( - 2 ) = . 135 and exp ( - 32 ) = 1 . 27 e - 14 .
Peak relative error 5.3e-21 */
#if UNK
static long double P1[10 ] = {
4 .302849750435552180717 E0L,
4 .360209451837096682600 E1L,
9 .454613328844768318162 E1L,
9 .336735653151873871756 E1L,
5 .305046472191852391737 E1L,
1 .775851836288460008093 E1L,
3 .640308340137013109859 E0L,
3 .691354900171224122390 E-1 L,
1 .403530274998072987187 E-2 L,
1 .377145111380960566197 E-4 L,
};
static long double Q1[9 ] = {
/* 1.000000000000000000000E0L, */
2 .001425109170530136741 E1L,
7 .079893963891488254284 E1L,
8 .033277265194672063478 E1L,
5 .034715121553662712917 E1L,
1 .779820137342627204153 E1L,
3 .845554944954699547539 E0L,
3 .993627390181238962857 E-1 L,
1 .526870689522191191380 E-2 L,
1 .498700676286675466900 E-4 L,
};
#endif
#if IBMPC
static short P1[] = {
0 x6105,0 xb71e,0 xf1f5,0 x89b0,0 x4001, XPD
0 x461d,0 x2604,0 x8b77,0 xae68,0 x4004, XPD
0 x8b33,0 x4a47,0 x9ec8,0 xbd17,0 x4005, XPD
0 xa0b2,0 xc1b0,0 x1627,0 xbabc,0 x4005, XPD
0 x9901,0 x28f7,0 xad06,0 xd433,0 x4004, XPD
0 xddcb,0 x5009,0 x7213,0 x8e11,0 x4003, XPD
0 x2432,0 x0fa6,0 xcfd5,0 xe8fa,0 x4000, XPD
0 x3e24,0 xd53c,0 x53b2,0 xbcff,0 x3ffd, XPD
0 x4058,0 x3d75,0 x5393,0 xe5f4,0 x3ff8, XPD
0 x1789,0 xf50a,0 x7524,0 x9067,0 x3ff2, XPD
};
static short Q1[] = {
/* 0x0000,0x0000,0x0000,0x8000,0x3fff, XPD */
0 xd901,0 x2673,0 x2fad,0 xa01d,0 x4003, XPD
0 x24f5,0 xc93c,0 x0e9d,0 x8d99,0 x4005, XPD
0 x8cda,0 x523a,0 x612d,0 xa0aa,0 x4005, XPD
0 x602c,0 xb5fc,0 x7b9b,0 xc963,0 x4004, XPD
0 xac72,0 xd3e7,0 xb766,0 x8e62,0 x4003, XPD
0 x048e,0 xe34c,0 x927c,0 xf61d,0 x4000, XPD
0 x6d88,0 xa5cc,0 x45de,0 xcc79,0 x3ffd, XPD
0 xe6d1,0 x199a,0 x9931,0 xfa29,0 x3ff8, XPD
0 x4c7d,0 x3675,0 x70a0,0 x9d26,0 x3ff2, XPD
};
#endif
#if MIEEE
static long P1[30 ] = {
0 x40010000,0 x89b0f1f5,0 xb71e6105,
0 x40040000,0 xae688b77,0 x2604461d,
0 x40050000,0 xbd179ec8,0 x4a478b33,
0 x40050000,0 xbabc1627,0 xc1b0a0b2,
0 x40040000,0 xd433ad06,0 x28f79901,
0 x40030000,0 x8e117213,0 x5009ddcb,
0 x40000000,0 xe8facfd5,0 x0fa62432,
0 x3ffd0000,0 xbcff53b2,0 xd53c3e24,
0 x3ff80000,0 xe5f45393,0 x3d754058,
0 x3ff20000,0 x90677524,0 xf50a1789,
};
static long Q1[27 ] = {
/* 0x3fff0000,0x80000000,0x00000000, */
0 x40030000,0 xa01d2fad,0 x2673d901,
0 x40050000,0 x8d990e9d,0 xc93c24f5,
0 x40050000,0 xa0aa612d,0 x523a8cda,
0 x40040000,0 xc9637b9b,0 xb5fc602c,
0 x40030000,0 x8e62b766,0 xd3e7ac72,
0 x40000000,0 xf61d927c,0 xe34c048e,
0 x3ffd0000,0 xcc7945de,0 xa5cc6d88,
0 x3ff80000,0 xfa299931,0 x199ae6d1,
0 x3ff20000,0 x9d2670a0,0 x36754c7d,
};
#endif
/* ndtri(x) = z - ln(z)/z - 1/z P2(1/z)/Q2(1/z)
z = sqrt ( - 2 ln ( y ) )
8 < = z < = 32
i . e . , y between exp ( - 32 ) = 1 . 27 e - 14 and exp ( - 512 ) = 4 . 38 e - 223
Peak relative error 1.0e-21 */
#if UNK
static long double P2[8 ] = {
3 .244525725312906932464 E0L,
6 .856256488128415760904 E0L,
3 .765479340423144482796 E0L,
1 .240893301734538935324 E0L,
1 .740282292791367834724 E-1 L,
9 .082834200993107441750 E-3 L,
1 .617870121822776093899 E-4 L,
7 .377405643054504178605 E-7 L,
};
static long double Q2[7 ] = {
/* 1.000000000000000000000E0L, */
6 .021509481727510630722 E0L,
3 .528463857156936773982 E0L,
1 .289185315656302878699 E0L,
1 .874290142615703609510 E-1 L,
9 .867655920899636109122 E-3 L,
1 .760452434084258930442 E-4 L,
8 .028288500688538331773 E-7 L,
};
#endif
#if IBMPC
static short P2[] = {
0 xafb1,0 x4ff9,0 x4f3a,0 xcfa6,0 x4000, XPD
0 xbd81,0 xaffa,0 x7401,0 xdb66,0 x4001, XPD
0 x3a32,0 x3863,0 x9d0f,0 xf0fd,0 x4000, XPD
0 x300e,0 x633d,0 x977a,0 x9ed5,0 x3fff, XPD
0 xea3a,0 x56b6,0 x74c5,0 xb234,0 x3ffc, XPD
0 x38c6,0 x49d2,0 x2af6,0 x94d0,0 x3ff8, XPD
0 xc85d,0 xe17d,0 x5ed1,0 xa9a5,0 x3ff2, XPD
0 x536c,0 x808b,0 x2542,0 xc609,0 x3fea, XPD
};
static short Q2[] = {
/* 0x0000,0x0000,0x0000,0x8000,0x3fff, XPD */
0 xaabd,0 x125a,0 x34a7,0 xc0b0,0 x4001, XPD
0 x0ded,0 xe6da,0 x5a11,0 xe1d2,0 x4000, XPD
0 xc742,0 x9d16,0 x0640,0 xa504,0 x3fff, XPD
0 xea1e,0 x4cc2,0 x643a,0 xbfed,0 x3ffc, XPD
0 x7a9b,0 xfaff,0 xf2dd,0 xa1ab,0 x3ff8, XPD
0 xfd90,0 x4688,0 xc902,0 xb898,0 x3ff2, XPD
0 xf003,0 x032a,0 xfa7e,0 xd781,0 x3fea, XPD
};
#endif
#if MIEEE
static long P2[24 ] = {
0 x40000000,0 xcfa64f3a,0 x4ff9afb1,
0 x40010000,0 xdb667401,0 xaffabd81,
0 x40000000,0 xf0fd9d0f,0 x38633a32,
0 x3fff0000,0 x9ed5977a,0 x633d300e,
0 x3ffc0000,0 xb23474c5,0 x56b6ea3a,
0 x3ff80000,0 x94d02af6,0 x49d238c6,
0 x3ff20000,0 xa9a55ed1,0 xe17dc85d,
0 x3fea0000,0 xc6092542,0 x808b536c,
};
static long Q2[21 ] = {
/* 0x3fff0000,0x80000000,0x00000000, */
0 x40010000,0 xc0b034a7,0 x125aaabd,
0 x40000000,0 xe1d25a11,0 xe6da0ded,
0 x3fff0000,0 xa5040640,0 x9d16c742,
0 x3ffc0000,0 xbfed643a,0 x4cc2ea1e,
0 x3ff80000,0 xa1abf2dd,0 xfaff7a9b,
0 x3ff20000,0 xb898c902,0 x4688fd90,
0 x3fea0000,0 xd781fa7e,0 x032af003,
};
#endif
/* ndtri(x) = z - ln(z)/z - 1/z P3(1/z)/Q3(1/z)
32 < z < 2048 / 13
Peak relative error 1.4e-20 */
#if UNK
static long double P3[8 ] = {
2 .020331091302772535752 E0L,
2 .133020661587413053144 E0L,
2 .114822217898707063183 E-1 L,
-6 .500909615246067985872 E-3 L,
-7 .279315200737344309241 E-4 L,
-1 .275404675610280787619 E-5 L,
-6 .433966387613344714022 E-8 L,
-7 .772828380948163386917 E-11 L,
};
static long double Q3[7 ] = {
/* 1.000000000000000000000E0L, */
2 .278210997153449199574 E0L,
2 .345321838870438196534 E-1 L,
-6 .916708899719964982855 E-3 L,
-7 .908542088737858288849 E-4 L,
-1 .387652389480217178984 E-5 L,
-7 .001476867559193780666 E-8 L,
-8 .458494263787680376729 E-11 L,
};
#endif
#if IBMPC
static short P3[] = {
0 x87b2,0 x0f31,0 x1ac7,0 x814d,0 x4000, XPD
0 x491c,0 xcd74,0 x6917,0 x8883,0 x4000, XPD
0 x935e,0 x1776,0 xcba9,0 xd88e,0 x3ffc, XPD
0 xbafd,0 x8abb,0 x9518,0 xd505,0 xbff7, XPD
0 xc87e,0 x2ed3,0 xa84a,0 xbed2,0 xbff4, XPD
0 x0094,0 xa402,0 x36b5,0 xd5fa,0 xbfee, XPD
0 xbc53,0 x0fc3,0 x1ab2,0 x8a2b,0 xbfe7, XPD
0 x30b4,0 x71c0,0 x223d,0 xaaed,0 xbfdd, XPD
};
static short Q3[] = {
/* 0x0000,0x0000,0x0000,0x8000,0x3fff, XPD */
0 xdfc1,0 x8a57,0 x357f,0 x91ce,0 x4000, XPD
0 xcc4f,0 x9e03,0 x346e,0 xf029,0 x3ffc, XPD
0 x38b1,0 x9788,0 x8f42,0 xe2a5,0 xbff7, XPD
0 xb281,0 x2117,0 x53da,0 xcf51,0 xbff4, XPD
0 xf2ab,0 x1d42,0 x3760,0 xe8cf,0 xbfee, XPD
0 x741b,0 xf14f,0 x06b0,0 x965b,0 xbfe7, XPD
0 x37c2,0 xa91f,0 x16ea,0 xba01,0 xbfdd, XPD
};
#endif
#if MIEEE
static long P3[24 ] = {
0 x40000000,0 x814d1ac7,0 x0f3187b2,
0 x40000000,0 x88836917,0 xcd74491c,
0 x3ffc0000,0 xd88ecba9,0 x1776935e,
0 xbff70000,0 xd5059518,0 x8abbbafd,
0 xbff40000,0 xbed2a84a,0 x2ed3c87e,
0 xbfee0000,0 xd5fa36b5,0 xa4020094,
0 xbfe70000,0 x8a2b1ab2,0 x0fc3bc53,
0 xbfdd0000,0 xaaed223d,0 x71c030b4,
};
static long Q3[21 ] = {
/* 0x3fff0000,0x80000000,0x00000000, */
0 x40000000,0 x91ce357f,0 x8a57dfc1,
0 x3ffc0000,0 xf029346e,0 x9e03cc4f,
0 xbff70000,0 xe2a58f42,0 x978838b1,
0 xbff40000,0 xcf5153da,0 x2117b281,
0 xbfee0000,0 xe8cf3760,0 x1d42f2ab,
0 xbfe70000,0 x965b06b0,0 xf14f741b,
0 xbfdd0000,0 xba0116ea,0 xa91f37c2,
};
#endif
#ifdef ANSIPROT
extern long double polevll ( long double , void *, int );
extern long double p1evll ( long double , void *, int );
extern long double logl ( long double );
extern long double sqrtl ( long double );
#else
long double polevll(), p1evll(), logl(), sqrtl();
#endif
long double ndtril(y0)
long double y0;
{
long double x, y, z, y2, x0, x1;
int code;
if ( y0 <= 0 .0 L )
{
mtherr( "ndtril" , DOMAIN );
return ( -MAXNUML );
}
if ( y0 >= 1 .0 L )
{
mtherr( "ndtri" , DOMAIN );
return ( MAXNUML );
}
code = 1 ;
y = y0;
if ( y > (1 .0 L - 0 .13533528323661269189 L) ) /* 0.135... = exp(-2) */
{
y = 1 .0 L - y;
code = 0 ;
}
if ( y > 0 .13533528323661269189 L )
{
y = y - 0 .5 L;
y2 = y * y;
x = y + y * (y2 * polevll( y2, P0, 7 )/p1evll( y2, Q0, 7 ));
x = x * s2pi;
return (x);
}
x = sqrtl( -2 .0 L * logl(y) );
x0 = x - logl(x)/x;
z = 1 .0 L/x;
if ( x < 8 .0 L )
x1 = z * polevll( z, P1, 9 )/p1evll( z, Q1, 9 );
else if ( x < 32 .0 L )
x1 = z * polevll( z, P2, 7 )/p1evll( z, Q2, 7 );
else
x1 = z * polevll( z, P3, 7 )/p1evll( z, Q3, 7 );
x = x0 - x1;
if ( code != 0 )
x = -x;
return ( x );
}
Messung V0.5 in Prozent C=96 H=100 G=97
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-14)
¤
*© Formatika GbR, Deutschland