Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

matvec::FDist Class Reference

#include <statdist.h>

Inheritance diagram for matvec::FDist:

matvec::StatDistBase List of all members.

Detailed Description

F statistical distribution.

Definition at line 227 of file statdist.h.

Public Methods

 FDist (const double df1, const double df2, const double nc=0.0)
 FDist (const FDist &u)
void display (void) const
void reset (const double df1, const double df2, const double nc=0.0)
void sample (Vector< double > &x) const
void sample (doubleMatrix &x) const
double sample (void) const
Vector< double > sample (unsigned n) const
doubleMatrix sample (unsigned m, unsigned n) const
double mean (void) const
double variance (void) const
double nonc (void) const
double pdf (const double x) const
double cdf (const double x) const
double mgf (const double t) const
double inv (const double p) const
double nonct (const double cv, const double p) const
double parameter (const int k) const
void parameter (const int k, const double x)
virtual const std::string name (void) const
virtual double nonct (const double cv, const double p)

Protected Attributes

double df1_value
double df2_value
double nc_value
std::string distname


Constructor & Destructor Documentation

matvec::FDist::FDist const double    df1,
const double    df2,
const double    nc = 0.0
[inline]
 

Definition at line 231 of file statdist.h.

References matvec::StatDistBase::distname, and reset().

00232                                 {distname="FDist"; reset(df1,df2,nc);}

matvec::FDist::FDist const FDist &    u [inline]
 

Definition at line 233 of file statdist.h.

References matvec::StatDistBase::distname, and reset().

00233                            :StatDistBase()
00234           {distname="FDist";reset(u.df1_value,u.df2_value,u.nc_value);}


Member Function Documentation

double matvec::FDist::cdf const double    x const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 248 of file statdist.h.

References df1_value, df2_value, matvec::F_cdf(), and nc_value.

00248                                         {int errcode=0;
00249                        return F_cdf(x,df1_value,df2_value,nc_value,errcode);}

void matvec::FDist::display void    const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 236 of file statdist.h.

References df1_value, df2_value, matvec::StatDistBase::distname, and nc_value.

00236                                   {std::cout << "\t" << distname << "(" << df1_value
00237                       << "," << df2_value<< ","<< nc_value << ")\n"; return;}

double matvec::FDist::inv const double    p const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 251 of file statdist.h.

References df1_value, df2_value, matvec::F_inv(), and nc_value.

00252                           {return F_inv(p,df1_value,df2_value,nc_value);}

double matvec::FDist::mean void    const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 645 of file statdist.cpp.

double matvec::FDist::mgf const double    t const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 639 of file statdist.cpp.

References df1_value, df2_value, and nc_value.

00639 {
00640    if (x < 0.0) throw exception("FDist::pdf(): bad arg, nonnegative value expected");
00641    if (nc_value != 0.0) throw exception("FDist::pdf():  not available yet: noncentrality");
00642    double r1 = df1_value;
00643    double r2 = df2_value;

virtual const std::string matvec::StatDistBase::name void    const [inline, virtual, inherited]
 

Definition at line 45 of file statdistbase.h.

References matvec::StatDistBase::distname.

00045 {return distname;}

double matvec::FDist::nonc void    const [inline]
 

Definition at line 246 of file statdist.h.

References nc_value.

00246 {return nc_value;}

virtual double matvec::StatDistBase::nonct const double    cv,
const double    p
[inline, virtual, inherited]
 

Definition at line 58 of file statdistbase.h.

00058 {std::cerr << "error\n"; return 0.0;}

double matvec::FDist::nonct const double    cv,
const double    p
const
 

Definition at line 663 of file statdist.cpp.

References df1_value, df2_value, and nc_value.

00665 {
00666    if (df2_value < 5) throw exception("FDist::variance(): not exist: df2 < 5");
00667    double x,v1,v2,t1,t2;
00668    v1 = df1_value;
00669    v2 = df2_value;
00670    x = v2 - 2.0;
00671    t1 = v2*v2*((v1+nc_value)*(v1+nc_value) + (v1+nc_value*2.0)*x);
00672    t2 = v1*v1*x*x*(v2 - 4.0);
00673    return t1/t2*2.0;
00674 }
00675 
00676 double FDist::nonct(const double cv,const double p) const
00677 {
00678    if (p<0.0 || p>1.0) throw exception("FDist::nonct(): bad arg, value between (0,1) expected");
00679    double p2,ppf;
00680    if (df2_value >= 3) {
00681       ppf = df2_value/(df2_value -2.0);
00682    }
00683    else {
00684       ppf = 0.0;
00685    }
00686    double eps = 1.0e-6;
00687    double bot = 0.0;
00688    double top = ppf + 6000.0;
00689    int errcode = 0;
00690    while (top-bot > eps) {
00691       ppf = (top + bot)*0.5;
00692       p2 = F_cdf(cv,df1_value,df2_value,ppf,errcode);

void matvec::FDist::parameter const int    k,
const double    x
[virtual]
 

Implements matvec::StatDistBase.

Definition at line 762 of file statdist.cpp.

00763                   {
00764       par = df2_value;
00765    }
00766    else if (k==3) {
00767       par = nc_value;
00768    }
00769    else {
00770       throw exception("FDist::parameter(): bad arg value, 1(2,3) is expected");
00771    }
00772    return par;
00773 }
00774 
00775 void FDist::parameter(const int k,const double x)
00776 {
00777    if (k==1) {
00778       if (x <= 0.0) {
00779          throw exception("FDist::parameter(): bad arg2, positives expected");
00780       }
00781       else {
00782          df1_value = x;
00783       }
00784    }
00785    else if (k==2) {
00786       if (x <= 0.0) {
00787          throw exception("FDist::parameter(): bad arg2, positives expected");
00788       }
00789       else {
00790          df2_value = x;
00791       }

double matvec::FDist::parameter const int    k const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 744 of file statdist.cpp.

References sample().

00744 {
00745    Vector<double> x(n);
00746    sample(x);
00747    return x;
00748 }
00749 
00750 doubleMatrix FDist::sample(unsigned m,unsigned n) const
00751 {
00752    doubleMatrix x(m,n);
00753    sample(x);
00754    return x;
00755 }
00756 
00757 double FDist::parameter(const int k) const
00758 {
00759    double par =  0.0;
00760    if (k==1) {

double matvec::FDist::pdf const double    x const [virtual]
 

If U1 is distributed as and U2 is ditributed as are independent then the random variable

is called the non-central F distribution with r1 (integer) and r2 (integer) degrees of freedom and non-centrality parameter (real).

Implements matvec::StatDistBase.

Definition at line 625 of file statdist.cpp.

References df1_value, df2_value, and nc_value.

00634             {U_1/r_1}{U_2/r_2}
00635 \f]
00636 is called the non-central F distribution with r1 (integer) and r2 (integer) degrees of freedom and non-centrality parameter \f$\delta\f$ (real).
00637 */

void matvec::FDist::reset const double    df1,
const double    df2,
const double    nc = 0.0
 

Definition at line 610 of file statdist.cpp.

Referenced by FDist().

00611                   {
00612       nc_value = x;
00613    }
00614    else {
00615       throw exception("tDist::parameter(): bad arg1");
00616    }
00617 }
00618 

doubleMatrix matvec::FDist::sample unsigned    m,
unsigned    n
const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 737 of file statdist.cpp.

References nc_value.

Vector< double > matvec::FDist::sample unsigned    n const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 730 of file statdist.cpp.

References matvec::genf().

00730                            {
00731          bot = x[i];  top = &bot[nc];
00732          while (bot < top ) *bot++ = genf(df1,df2);
00733       }
00734    }
00735    else {

double matvec::FDist::sample void    const [inline, virtual]
 

Implements matvec::StatDistBase.

Definition at line 241 of file statdist.h.

References df1_value, df2_value, and matvec::genf().

Referenced by parameter().

00241 {return genf(int(df1_value),int(df2_value));}

void matvec::FDist::sample doubleMatrix   x const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 708 of file statdist.cpp.

References matvec::genf(), matvec::gennf(), and nc_value.

00708 {
00709    double *bot = x.begin();
00710    double *top = x.end();
00711    int df1 = static_cast<int>(df1_value);
00712    int df2 = static_cast<int>(df2_value);
00713    if (nc_value == 0.0) {
00714       while (bot < top ) *bot++ = genf(df1,df2);
00715    }
00716    else {
00717       while (bot < top ) *bot++ = gennf(df1,df2,nc_value);
00718    }
00719 }
00720 
00721 void FDist::sample(doubleMatrix& x) const
00722 {
00723    int nr = x.num_rows();
00724    int nc = x.num_cols();
00725    double *bot,*top;
00726    unsigned i;
00727    int df1 = static_cast<int>(df1_value);
00728    int df2 = static_cast<int>(df2_value);

void matvec::FDist::sample Vector< double > &    x const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 694 of file statdist.cpp.

00694                    {
00695          top = ppf;
00696       }
00697       else if (p2 > p) {
00698          bot = ppf;
00699       }
00700       else {
00701          break;
00702       }
00703    }
00704    return ppf;
00705 }
00706 

double matvec::FDist::variance void    const [virtual]
 

Implements matvec::StatDistBase.

Definition at line 651 of file statdist.cpp.

00653 {
00654    throw exception("FDist:mgf(): not available yet");
00655    return 0.0;
00656 }
00657 
00658 double FDist::mean(void) const
00659 {
00660    if (df2_value < 3 ) throw exception(" FDist::mean(): not exist:  df2 < 3");
00661    return df2_value*(df1_value + nc_value)/(df1_value*(df2_value - 2.0));


Member Data Documentation

double matvec::FDist::df1_value [protected]
 

Definition at line 229 of file statdist.h.

Referenced by cdf(), display(), inv(), mgf(), nonct(), pdf(), and sample().

double matvec::FDist::df2_value [protected]
 

Definition at line 229 of file statdist.h.

Referenced by cdf(), display(), inv(), mgf(), nonct(), pdf(), and sample().

std::string matvec::StatDistBase::distname [protected, inherited]
 

Definition at line 39 of file statdistbase.h.

Referenced by matvec::BetaDist::BetaDist(), matvec::BinomialDist::BinomialDist(), matvec::ChiSquareDist::ChiSquareDist(), matvec::DiscreteUniformDist::DiscreteUniformDist(), matvec::NegativeBinomialDist::display(), matvec::GeometricDist::display(), matvec::PoissonDist::display(), matvec::BinomialDist::display(), matvec::DiscreteUniformDist::display(), matvec::BetaDist::display(), matvec::ExponentialDist::display(), matvec::GammaDist::display(), display(), matvec::tDist::display(), matvec::ChiSquareDist::display(), matvec::LogNormalDist::display(), matvec::NormalDist::display(), matvec::UniformDist::display(), matvec::ExponentialDist::ExponentialDist(), FDist(), matvec::GammaDist::GammaDist(), matvec::GeometricDist::GeometricDist(), matvec::LogNormalDist::LogNormalDist(), matvec::StatDistBase::name(), matvec::NegativeBinomialDist::NegativeBinomialDist(), matvec::NormalDist::NormalDist(), matvec::PoissonDist::PoissonDist(), matvec::StatDistBase::StatDistBase(), matvec::tDist::tDist(), and matvec::UniformDist::UniformDist().

double matvec::FDist::nc_value [protected]
 

Definition at line 229 of file statdist.h.

Referenced by cdf(), display(), inv(), mgf(), nonc(), nonct(), pdf(), and sample().


The documentation for this class was generated from the following files:
Generated on Thu Jun 16 17:14:21 2005 for Matvec by doxygen1.2.16