/*2:*/
#line 87 "statlib.w"

#include "config.h"                   


#line 90 "statlib.w"


/*4:*/
#line 121 "statlib.w"

#include "dcdflib.h"        
#include "statlib.h"        

/*:4*/
#line 92 "statlib.w"

/*5:*/
#line 129 "statlib.w"

/*11:*/
#line 379 "statlib.w"

double normalDistribution::p_from_mu_sigma_x(double mu,double sigma,double x){
double p,q,bound;
int which= 1,status;

cdfnor(&which,&p,&q,&x,&mu,&sigma,&status,&bound);
if(status!=0){
throw(out_of_range("normalDistribution::p_from_mu_sigma_x: Result out of bounds"));
}
return p;
}

double normalDistribution::x_from_p_mu_sigma(double p,double mu,double sigma){
double q,x,bound;
int which= 2,status;

q= 1-p;
cdfnor(&which,&p,&q,&x,&mu,&sigma,&status,&bound);
if(status!=0){
throw(out_of_range("normalDistribution::x_from_p_mu_sigma: Result out of bounds"));
}
return x;
}

double normalDistribution::mu_from_p_x_sigma(double p,double x,double sigma){
double q,mu,bound;
int which= 3,status;

q= 1-p;
cdfnor(&which,&p,&q,&x,&mu,&sigma,&status,&bound);
if(status!=0){
throw(out_of_range("normalDistribution::mu_from_p_x_sigma: Result out of bounds"));
}
return mu;
}

double normalDistribution::sigma_from_p_x_mu(double p,double x,double mu){
double q,sigma,bound;
int which= 4,status;

q= 1-p;
cdfnor(&which,&p,&q,&x,&mu,&sigma,&status,&bound);
if(status!=0){
throw(out_of_range("normalDistribution::sigma_from_p_x_mu: Result out of bounds"));
}
return sigma;
}

/*:11*//*12:*/
#line 435 "statlib.w"

double normalDistribution::CDF_P(double x){
return p_from_mu_sigma_x(mu,sigma,x);
}

/*:12*//*14:*/
#line 549 "statlib.w"

double chiSquareDistribution::p_from_k_x(double k,double x){
double p,q,bound;
int which= 1,status;

cdfchi(&which,&p,&q,&x,&k,&status,&bound);
if(status!=0){
throw(out_of_range("chiSquareDistribution::p_from_k_x: Result out of bounds"));
}
return p;
}

double chiSquareDistribution::x_from_p_k(double p,double k){
double q,x,bound;
int which= 2,status;

q= 1-p;
cdfchi(&which,&p,&q,&x,&k,&status,&bound);
if(status!=0){
throw(out_of_range("chiSquareDistribution::x_from_p_k: Result out of bounds"));
}
return x;
}

double chiSquareDistribution::k_from_p_x(double p,double x){
double q,k,bound;
int which= 3,status;

q= 1-p;
cdfchi(&which,&p,&q,&x,&k,&status,&bound);
if(status!=0){
throw(out_of_range("chiSquareDistribution::k_from_p_x: Result out of bounds"));
}
return k;
}

/*:14*//*15:*/
#line 593 "statlib.w"

double chiSquareDistribution::CDF_P(double x){
return p_from_k_x(k,x);
}

/*:15*//*17:*/
#line 709 "statlib.w"

double gammaDistribution::p_from_alpha_lambda_x(double alpha,double lambda,double x){
double p,q,bound;
int which= 1,status;

cdfgam(&which,&p,&q,&x,&alpha,&lambda,&status,&bound);
if(status!=0){
throw(out_of_range("gammaDistribution::p_from_alpha_lambda_x: Result out of bounds"));
}
return p;
}

double gammaDistribution::x_from_p_alpha_lambda(double p,double alpha,double lambda){
double q,x,bound;
int which= 2,status;

q= 1-p;
cdfgam(&which,&p,&q,&x,&alpha,&lambda,&status,&bound);
if(status!=0){
throw(out_of_range("gammaDistribution::x_from_p_alpha_lambda: Result out of bounds"));
}
return x;
}

double gammaDistribution::alpha_from_p_lambda_x(double p,double lambda,double x){
double q,alpha,bound;
int which= 3,status;

q= 1-p;
cdfgam(&which,&p,&q,&x,&alpha,&lambda,&status,&bound);
if(status!=0){
throw(out_of_range("gammaDistribution::alpha_from_p_lambda_x: Result out of bounds"));
}
return alpha;
}

double gammaDistribution::lambda_from_p_alpha_x(double p,double alpha,double x){
double q,lambda,bound;
int which= 4,status;

q= 1-p;
cdfgam(&which,&p,&q,&x,&alpha,&lambda,&status,&bound);
if(status!=0){
throw(out_of_range("gammaDistribution::lambda_from_p_alpha_x: Result out of bounds"));
}
return lambda;
}

/*:17*//*18:*/
#line 761 "statlib.w"

double gammaDistribution::CDF_P(double x){
return p_from_alpha_lambda_x(alpha,lambda,x);
}

/*:18*//*20:*/
#line 880 "statlib.w"

double betaDistribution::p_from_a_b_x(double a,double b,double x){
double p,q,y,bound;
int which= 1,status;

y= 1-x;
cdfbet(&which,&p,&q,&x,&y,&a,&b,&status,&bound);
if(status!=0){
throw(out_of_range("betaDistribution::p_from_a_b_x: Result out of bounds"));
}
return p;
}

double betaDistribution::x_from_p_a_b(double p,double a,double b){
double q,x,y,bound;
int which= 2,status;

q= 1-p;
cdfbet(&which,&p,&q,&x,&y,&a,&b,&status,&bound);
if(status!=0){
throw(out_of_range("betaDistribution::x_from_p_a_b: Result out of bounds"));
}
return x;
}

double betaDistribution::a_from_p_b_x(double p,double b,double x){
double a,q,y,bound;
int which= 3,status;

q= 1-p;
y= 1-x;
cdfbet(&which,&p,&q,&x,&y,&a,&b,&status,&bound);
if(status!=0){
throw(out_of_range("betaDistribution::a_from_p_b_x: Result out of bounds"));
}
return a;
}

double betaDistribution::b_from_p_a_x(double p,double a,double x){
double b,q,y,bound;
int which= 4,status;

q= 1-p;
y= 1-x;
cdfbet(&which,&p,&q,&x,&y,&a,&b,&status,&bound);
if(status!=0){
throw(out_of_range("betaDistribution::b_from_p_a_x: Result out of bounds"));
}
return b;
}

/*:20*//*21:*/
#line 935 "statlib.w"

double betaDistribution::CDF_P(double x){
return p_from_a_b_x(a,b,x);
}

/*:21*//*23:*/
#line 1039 "statlib.w"

double tDistribution::p_from_k_x(double k,double x){
double p,q,bound;
int which= 1,status;

cdft(&which,&p,&q,&x,&k,&status,&bound);
if(status!=0){
throw(out_of_range("tDistribution::p_from_k_x: Result out of bounds"));
}
return p;
}

double tDistribution::x_from_p_k(double p,double k){
double q,x,bound;
int which= 2,status;

q= 1-p;
cdft(&which,&p,&q,&x,&k,&status,&bound);
if(status!=0){
throw(out_of_range("tDistribution::x_from_p_k: Result out of bounds"));
}
return x;
}

double tDistribution::k_from_p_x(double p,double x){
double q,k,bound;
int which= 3,status;

q= 1-p;
cdft(&which,&p,&q,&x,&k,&status,&bound);
if(status!=0){
throw(out_of_range("tDistribution::k_from_p_x: Result out of bounds"));
}
return k;
}

/*:23*//*24:*/
#line 1083 "statlib.w"

double tDistribution::CDF_P(double x){
return p_from_k_x(k,x);
}

/*:24*//*26:*/
#line 1204 "statlib.w"

double FDistribution::p_from_u_v_x(double u,double v,double x){
double p,q,bound;
int which= 1,status;

cdff(&which,&p,&q,&x,&u,&v,&status,&bound);
if(status!=0){
throw(out_of_range("FDistribution::p_from_u_v_x: Result out of bounds"));
}
return p;
}

double FDistribution::x_from_p_u_v(double p,double u,double v){
double q,x,bound;
int which= 2,status;

q= 1-p;
cdff(&which,&p,&q,&x,&u,&v,&status,&bound);
if(status!=0){
throw(out_of_range("FDistribution::x_from_p_u_v: Result out of bounds"));
}
return x;
}

double FDistribution::u_from_p_v_x(double p,double v,double x){
double q,u,bound;
int which= 3,status;

q= 1-p;
cdff(&which,&p,&q,&x,&u,&v,&status,&bound);
if(status!=0){
throw(out_of_range("FDistribution::u_from_p_v_x: Result out of bounds"));
}
return u;
}

double FDistribution::v_from_p_u_x(double p,double u,double x){
double q,v,bound;
int which= 4,status;

q= 1-p;
cdff(&which,&p,&q,&x,&u,&v,&status,&bound);
if(status!=0){
throw(out_of_range("FDistribution::v_from_p_u_x: Result out of bounds"));
}
return v;
}

/*:26*//*27:*/
#line 1256 "statlib.w"

double FDistribution::CDF_P(double x){
return p_from_u_v_x(u,v,x);
}

/*:27*//*29:*/
#line 1351 "statlib.w"

double poissonDistribution::p_from_lambda_x(double lambda,double x){
double p,q,bound;
int which= 1,status;

cdfpoi(&which,&p,&q,&x,&lambda,&status,&bound);
if(status!=0){
throw(out_of_range("poissonDistribution::p_from_lambda_x: Result out of bounds"));
}
return p;
}

double poissonDistribution::x_from_p_lambda(double p,double lambda){
double q,x,bound;
int which= 2,status;

q= 1-p;
cdfpoi(&which,&p,&q,&x,&lambda,&status,&bound);
if(status!=0){
throw(out_of_range("poissonDistribution::x_from_p_lambda: Result out of bounds"));
}
return x;
}

double poissonDistribution::lambda_from_p_x(double p,double x){
double q,lambda,bound;
int which= 3,status;

q= 1-p;
cdfpoi(&which,&p,&q,&x,&lambda,&status,&bound);
if(status!=0){
throw(out_of_range("poissonDistribution::lambda_from_p_x: Result out of bounds"));
}
return lambda;
}

/*:29*//*30:*/
#line 1395 "statlib.w"

double poissonDistribution::CDF_P(double x){
return p_from_lambda_x(lambda,x);
}

/*:30*//*32:*/
#line 1521 "statlib.w"

double binomialDistribution::p_from_n_r_s(double n,double r,double s){
double p,q,ri,bound;
int which= 1,status;

ri= 1-r;
cdfbin(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("binomialDistribution::p_from_n_r_s: Result out of bounds"));
}
return p;
}

double binomialDistribution::s_from_p_r_n(double p,double r,double n){
double q,ri,s,bound;
int which= 2,status;

q= 1-p;
ri= 1-r;
cdfbin(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("binomialDistribution::s_from_p_r_n: Result out of bounds"));
}
return s;
}

double binomialDistribution::n_from_p_r_s(double p,double r,double s){
double q,n,ri,bound;
int which= 3,status;

q= 1-p;
ri= 1-r;
cdfbin(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("binomialDistribution::n_from_p_r_s: Result out of bounds"));
}
return n;
}

double binomialDistribution::r_from_p_n_s(double p,double n,double s){
double q,r,ri,bound;
int which= 4,status;

q= 1-p;
cdfbin(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("binomialDistribution::r_from_p_n_s: Result out of bounds"));
}
return r;
}

/*:32*//*33:*/
#line 1580 "statlib.w"

double binomialDistribution::CDF_P(double x){
return p_from_n_r_s(n,r,x);
}

/*:33*//*35:*/
#line 1697 "statlib.w"

double negativeBinomialDistribution::p_from_n_r_s(double n,double r,double s){
double p,q,ri,bound;
int which= 1,status;

ri= 1-r;
cdfnbn(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("negativeBinomialDistribution::p_from_n_r_s: Result out of bounds"));
}
return p;
}

double negativeBinomialDistribution::s_from_p_r_n(double p,double r,double n){
double q,ri,s,bound;
int which= 2,status;

q= 1-p;
ri= 1-r;
cdfnbn(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("negativeBinomialDistribution::s_from_p_r_n: Result out of bounds"));
}
return s;
}

double negativeBinomialDistribution::n_from_p_r_s(double p,double r,double s){
double q,n,ri,bound;
int which= 3,status;

q= 1-p;
ri= 1-r;
cdfnbn(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("negativeBinomialDistribution::n_from_p_r_s: Result out of bounds"));
}
return n;
}

double negativeBinomialDistribution::r_from_p_n_s(double p,double n,double s){
double q,r,ri,bound;
int which= 4,status;

q= 1-p;
cdfnbn(&which,&p,&q,&s,&n,&r,&ri,&status,&bound);
if(status!=0){
throw(out_of_range("negativeBinomialDistribution::r_from_p_n_s: Result out of bounds"));
}
return r;
}

/*:35*//*36:*/
#line 1752 "statlib.w"

double negativeBinomialDistribution::CDF_P(double x){
return p_from_n_r_s(n,r,x);
}

/*:36*/
#line 130 "statlib.w"


/*:5*/
#line 93 "statlib.w"


/*:2*/


syntax highlighted by Code2HTML, v. 0.9.1