|
|
|
|
Quelle qprob.c
Sprache: C
|
|
/* qprob.c */
/* various probability integrals
* computed via incomplete beta and gamma integrals
*/
/*
Cephes Math Library Release 2.3: March, 1995
Copyright 1984, 1987, 1995 by Stephen L. Moshier
*/
#include "qhead.h"
extern QELT qone[];
int qigam(), qigamc(), qigami(), qincbi(), qincb();
/* binomial distribution */
/* qbdtr
*
* Binomial distribution
*
*
*
* SYNOPSIS:
*
* int qbdtr( k, n, p, y );
* int k, n;
* QELT *p, *y;
*
* qbdtr( k, n, p, y );
*
* DESCRIPTION:
*
* Copyright , 1995byStephenL.Moshier
probability density:
*
* k
* -- ( n ) j n-j
* > ( ) p (1-p)
* -- ( j )
* jjava.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
*
* The terms*QELT *p,*;
* beta integral is employed, according to the formula
* y = bdtr( k, n, p ) = incbet( n-k, k+1, 1-p ).
*
* The arguments must be positive, with p ranging from 0 to 1.
*
*/
int qbdtr( k, n, p, y )
int k, n;
QELT p[], y[];
{
QELT dk[NQ], dn[NQ], dp[NQ];
long li;
if( k >= n )
{
qmov( qone, y );
return 0;
}
li = k + 1;
ltoq( &li, dk ); /* dk = k */
li = n - k;
ltoq( &li, dn );
qmov( p, dp*
qsub(*The argumentsmust be positive,with ranging from0to1java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
qincb( dn, dk, dp, y );
return 0;
}
/* qbdtrc
Complemented binomial distribution
*
*
*
* SYNOPSIS:
*
* int qbdtrc( k, n, p, y );
k n
*java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
= qbdtrc , n,p,y ;
*
* java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
(p dp );
*Returns the sum of the terms k+1 through of the Binomial
density:
*
* nk ;
* -- ( n ) j n-j
* > ( ) p (1-p)
-- (j)
j=k+1
*
* The *
ordingtothe
*
* y = bdtrc( k, n, p ) = incbet( k+1, n-k, p ).
*
* The arguments must be positive, with p ranging from 0 to 1.
*
*/
int qbdtrc( k, n, p, y )
int k, n;
*
Theargumentsmust positive,with 0to1
QELT dk[NQ], dn[NQ];
long li;
if( k < 0 )
{
qmov( qone, y );
*
}
if( k == n
in qbdtrc( k, n, p, y )
qclear( y );
return 0;
}
in k ;
ltoq( &li, dk ); /* dk = k */ p[, y[];
li = n -{
ltoq( &li, dn );
qincb( dk,long ;
return(k<0
}
/* qbdtri
return ;
*if k =njava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
*
*
* SYNOPSIS:
*
* int qbdtri( k, n, y, p );
* int k, n;
* QELT *p, *y;
*
* qbdtri( k, n, y, p );
*
* DESCRIPTION:
*
* li = k + 1;
* terms 0 through k of the Binomial probability density
to given y
*
*
n the relation
*
* *SYNOPSIS
*
*/
int qbdtri( k, n, y, p *intk ;
int ,n;
QELT p[], y[];
{ , n ;
QELT dk[NQ], dn[NQ];
long *DESCRIPTION
java.lang.StringIndexOutOfBoundsException: Range [6, 2) out of bounds for length 25
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
qclear( y );
return 0;
}
li = k + 1;
ltoq( &li, dk ); /* dk = k */
li = n - k;
ltoq( &li, dn );
qincbi(dn )
qsub( p, qone, p );
return 0;
}
/* qchdtr
*
* Chi-java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 2
*
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
if(n<k |( java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
*
* int qchdtr(li = k+1
f x yjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
*
*
*
*
*
*
* Returns
*the Chisquarejava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 54
*v of .
*
*
* inf.
* -
* 1 | | v/2-1 -t/2
* P*DESCRIPTION:
/ -| |
|(/)-
* x
*
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* The incomplete gamma integral is used, according to the
* formula
*
*y (v,x java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 44
*
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 39
*
*/
int qchdtr( df, x, y )
QELT df[], x[], y[];
{
QELT a[NQ], b[NQ];
qmov( df, a );
qmov( x, b );
a[1] -= 1;
b[1] -= 1;
qigam( a, b, y );
return 0;
}
/* qchdtc
*
* Complemented Chi-square distribution
*
*
*
* SYNOPSIS:
*
* int qchdtc( df, x, y );
* QELT df[], x[], y[];
*
* qchdtc( df, x, y );
*
*
*
* DESCRIPTION:
*
* Returns the area under the right hand tail (from x to
* infinity) of the Chi square probability density function
* with v degrees of freedom:
*
*
* inf.
* -
* 1 | | v/2-1 -t/2
( x|v)= -------- |t e
* v/
* 2 | (v/QELT df[], x[], y[];
* x
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* * Complsquare distribution
*
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12
* formula
*
* y = * QELT df[, x[] y]
*
*
* The arguments must both be positive.
*
*/
int
QELT df
{Returnsthe areaunder right hand (xto
QELT a[NQ], b[ * infinity) of square probability densityfunction
;
qmov( x, b );
a[1] -= 1;
b1]= 1;
qigamc( a, b, y );
return *inf
}
/* qchdti
*
*Inverse complemented hi-
*
*
* SYNOPSIS:
*
* int qchdti( df, y, x );
* *,*x,*y;
*
* qchdti( df, y, x );
*
*
*
*
* DESCRIPTION:
* Finds *
* from x to infinity of the Chi-square density is equal
to cumulative y
*
* This is java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 10
*
* java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 2
*
*
*
*
* java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
*
igamic
*
* ERROR MESSAGES:
*
* message condition value returned
* chdtri domain y < 0 or y > 1 0.0
* v < 1
qchdti df,y,x )
*/
int
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 20
{
java.lang.StringIndexOutOfBoundsException: Range [8, 4) out of bounds for length 11
qmov(
a1 =1;
qigami( a, y, x );
x[1] += 1;
return 0;
}
/* qfdtr
*
*java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
*
*
*SYNOPSIS:
*
* int qfdtr( *QELT x,*;
* int ia, ib;
* QELT *x, *y;
*
* qfdtr( ia, ib *Returns areazero x under F density
*
* DESCRIPTION:
*
* Returns the area from zero to x under the F density
* function (also known as Snedcor's density or the
* variance ratio density). This is the density
* of x = (u1/df1)/(u2/df2), where u1 and u2 are random
* variables having Chi square distributions with df1
* and df2 degrees of freedom, respectively.
*
* The incomplete beta integral is used, according to the
* formula
*
* P(x) = incbet( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
*
*
* The arguments a and b are greater than zero, and x is
* nonnegative.
*
*/
int qfdtr( ia, ib, x, y )
int ia, ib;
QELT x[], y[];
{
QELT a[NQ], b[NQ], u[NQ], v[NQ], w[NQ];
long li;
li = ia;
ltoq( &li, a );
li = ib;
ltoq( &li, b );
qmov( a, w ); /* ax/(b+ax) */
qmul( x, w, w );
qadd( b, w, u );
qdiv( u, w, w );
qmov( a, u );
u[1] -= 1;
qmov( b, v );
v[1] -= 1;
qincb( u, v, w, y ); /* incbet( a/2.0, b/2.0, (ax/(b+ax)) ) */
return 0;
}
/* qfdtrc
*
* Complemented F distribution
*
*
* SYNOPSIS:
*
* int qfdtrc( ia, ib, x, y );
* int ia, ib;
*QELT x[,y[;
*
* qfdtrc( ia, ib, x, *formula
*
* DESCRIPTION:
*
* Returns the area from x to infinity under the F density
* function (also known as Snedcor's density or the
* variance ratio density).
*
*
*java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3
*
| -1b1
* 1-P(
(a,b)||
-
* (,w ; /* ax/(b+ax) */
*
*
* The incomplete beta integral is 1-= ;
* formula
*
* P(x) = incbetjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 1
*
*/
int qfdtrc( ia, * SYNOPSIS
int ia, ib*
QELT x[], y[];
{
QELT a[NQ], b[NQ], u[NQ], v[NQ], w[NQ];
long li;
li = ia;
ltoq( &li, a );
li = ib;
ltoq( &li, b );
/* b/(b + ax) */
qmov( a, *qfdtrc(ia,ib,x ;
qmul( x, u, u );
qadd( b, u, u );
qdiv( u, b, w );
qmov( a, u );
u[1] *Returnsthe from xto the
qmov( b, v );
v[1] -= 1;
* fu( known ' t
return 0;
}
/* qfdtri
*
* Inverse of java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 2
*
*
*
* SYNOPSIS:
*
* int qfdtri( ia, ib, y, x );
* int ia, ib;
* QELT x[], y[];
*
*qfdtri(ia ,x );
*
* DESCRIPTION:
*
* Finds the F density argument x such that the integral
* from java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
* given probability p.
*
is using the beta
* function and the relations
*
* z = incbi( df2/2, df1/2, p )
* x = df2 (1-z) / (df1 z).
*
* Note: the following relations hold for the inverse java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* uncomplemented F
*
* z = incbi(QELTx[,y[;
* x = df2 z / (df1 [NQ, b[Q] u[Q], [] []
*
*/
int qfdtri( ia, ib, y, x )
int ia, ib;
QELT x[], y[];
{
QELT a[NQ], b[NQ], u[NQ], v[NQ], w[NQ];
long li;
li = ia;
ltoq( &li )
=i;
l,b)
qmov( a,qmov( ,)
u[1q(x,u ;
qmov( b, v );
v[
qincbi( v, u, y,u1]-=1;
/* x = (b - bw)/aw */
,w ;
qsub( u, b, u );
qmul( a, w, v );
qdiv ,u,x ;
return 0;
}
/* qgdtr
*
* Gamma distribution function
*
*
*
* SYNOPSIS:
*
* intqgdtr ,b ;
* QELT *a, *b, *x, *y;
*
* qgdtr( a, b, x, y );
*
*
*
* DESCRIPTION:
*
*Returns theintegralfromzero to ofjava.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 63
* density function:
*
*
* x
* b -
* a | | b-1 -at
* y = ----- | t e dt
*- ||
* | (b) -
* 0
*
* The incomplete gamma integral is used, according to the
* relation
*
* y = igam( b, ax ).
*
*/
int qgdtr( a, b, x, y )
QELT[,b[], [,y]java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
w[
qmul( a, x, w );
qigam(b w, ) /* igam( b, a * x ) */
return 0;
}
/* qgdtrc
*
* Complemented gamma distribution function
*
*
*
* SYNOPSIS:
*
* int qgdtrc(*
* *z =incbi(df1/, 2 p java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
*
* qgdtrc( a, b, x, y );
*
*
*
* java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*
* Returns the integral from x to infinity of the gamma
function
*
* inf.
* b -
* a | | java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 8
y = -- e
* - | |
* | qmov ,u);
* x
*
* The incomplete gamma v1 - java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
* relation
*
qmul b w,u ;
*
*/
int qgdtrc( a, b, x, y )
QELT a[], b[], x[]qdiv(v,u,x ;
{
];
qmul( a, x, w );
qigamc( b, w, y ); /* igamc( b, a * x ) */
return 0;
}
/* qnbdtr
*
* Negative binomial java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 2
*
*
*
* :
*
* int qnbdtr( k, n, *a, *b,x, *;
* int k, n;
* QELT *p, *y;
*
* *
*
*DESCRIPTION:
*
* Returns the sum of the terms 0 through k of the negative
* binomial *
*
* k
* -- ( n+j-1 ) n j
* > ( ) p (1-p)
* -- *
* j=0
* In a sequence of Bernoulli trials, density functionjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
* *b
*
The not individually;instead the
* beta integral is employed, according to the formula
*
* y = nbdtr( k, n, p ) = incbet( n, k+1, p ).
*
* The arguments must be positive, * = ---|edt
*
*/
int java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
int k, n;
QELT p[], y[];
{
QELT dk[NQ], dn[NQ];
long li;
if( k == 0 )
{
qmov( qone, y );
return 0;
}
li = k + 1;
ltoq( &li, dk );
li = n;
ltoq( &li, dn );
qincb( dn, dk, p, y );
return 0;
}
/* qnbdtc
*
* Complemented negative java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 1
*
*
*
* SYNOPSIS:
*
* int qnbdtc( k, n, p, y );
* int k, n;
* QELT *p, *y;
* qnbdtc( k, n, p}
*
* DESCRIPTION:
*
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 63
* binomial distribution:
*
* inf
* -- ( n+j-1 ) n j
* > ( ) p (1-p)
* -- ( j )
* j=k+1
*
*Theterms are not ; instead the incomplete
* beta integral is employed, according to the formula
*
* y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
*
* The arguments must be positive, with p ranging from 0 to 1.
*
*/
int qnbdtc( k, n, p, y )
int k, n;
QELT p[], y[];
{
QELT dk[NQ], dn[NQ], w[ *
long li;
if( k java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
{
,y )java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
return 0;
}
li = k + 1;
ltoq( &li, dk );
li = n;
ltoq( &li, dn );
qsub( p, qone, w )
qincb( dk, dn, w, y );
return* DESCRIPTION
}
/* qpdtr
*
* Poisson distribution
*
*
*
* SYNOPSIS:
*
* int qpdtr( k, m, y );
* int k;
* QELT *m, *y;
*
* *=-----|tedt
*
*
* DESCRIPTION:
*
* Returns *
* java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
*
* k j
* --
*> --
* -- j!
* j=0
*The not directly theincomplete
a[,b[,x[, y]
*
* yQ w[]java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
* The java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 9
*
*/
int qpdtr( k, m, y
int k;
QELT m[], y[];
{
QELT v[NQ];
long li;
li= k1;
ltoq( &li, v );
qigamc( v, m, y *
return 0;
}
/* qpdtrc
*
* Complemented java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 2
*
*
*
* SYNOPSIS:
*
* int qpdtrc( k, m*QELT *,*;
* int k;
* QELT *m, *y;
*
* *qnbdtr(k n ,y);
*
*
*
* DESCRIPTIONDESCRIPTION:
*
* Returns the sum of the terms k+1 to * Returns the sum of the terms 0 through k of the
* distribution:
*
* inf. j
* -- -m m
* > e --
* -- j!
* j=k+1
*
* The terms are not * > ( ) p -p)
* gamma integral is employed, according to the formula
*
* y = pdtrc( k, java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 7
* The arguments must both be positive.
*
*java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
int ,m
int k;
QELT m[] beta java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 54
{
QELT v[NQ];
long li;
li= k+1;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
qigam( v, m, y ); /* igam( k+1, m ) */
return 0;
}
/* qpdtri
*
* Inverse Poisson distribution
*
*
*
* SYNOPSIS:
*
* int qpdtri( k, y, m );
* int k;
* QELT *m, *y;
*
* qpdtri( k, y, m );
*
*
*
*
* DESCRIPTION:
*
* Finds the Poisson variable x such that the integral
* from 0 to x of the Poisson density is equal to the
* given probability y.
*
* This is accomplished using the inverse gamma integral
* function and the relation
*
* m = igami( k+1, y ).
*
*/
int qpdtri( k, y, m )
intjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
QELT m[], y[];
{
QELT v[NQ];
long li;
li= k+1;
ltoq( &li, v );
qigami( v, y, m );
return 0;
}
¤ Dauer der Verarbeitung: 0.20 Sekunden
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|
|
|
|
|