#include <statdist.h>
Inheritance diagram for matvec::ChiSquareDist:

Definition at line 157 of file statdist.h.
Public Methods | |
| ChiSquareDist (const double df, const double nc=0.0) | |
| ChiSquareDist (const ChiSquareDist &u) | |
| void | display (void) const |
| void | reset (const double df, 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 | df_value |
| double | nc_value |
| std::string | distname |
|
||||||||||||
|
Definition at line 161 of file statdist.h. References matvec::StatDistBase::distname, and reset().
|
|
|
Definition at line 163 of file statdist.h. References matvec::StatDistBase::distname, and reset().
00163 :StatDistBase() 00164 {distname="ChiSquareDist";reset(u.df_value,u.nc_value);} |
|
|
Implements matvec::StatDistBase. Definition at line 178 of file statdist.h. References matvec::ChiSquare_cdf(), df_value, and nc_value.
00178 {int errcode=0;
00179 return ChiSquare_cdf(x,df_value,nc_value,errcode);}
|
|
|
Implements matvec::StatDistBase. Definition at line 166 of file statdist.h. References df_value, matvec::StatDistBase::distname, and nc_value.
|
|
|
Implements matvec::StatDistBase. Definition at line 181 of file statdist.h. References matvec::ChiSquare_inv(), df_value, and nc_value.
00181 {
00182 return ChiSquare_inv(p,df_value,nc_value);}
|
|
|
Implements matvec::StatDistBase. Definition at line 174 of file statdist.h. References df_value, and nc_value.
|
|
|
Implements matvec::StatDistBase. Definition at line 369 of file statdist.cpp. References df_value, and nc_value.
00371 {
00372 if (nc_value != 0.0) throw exception("ChiSquareDist::pdf(): not available yet: noncentrality");
00373 if ( x < 0.0) throw exception("ChiSquareDist::pdf(): bad arg, nonnegative value expected");
00374 double pr;
|
|
|
Definition at line 45 of file statdistbase.h. References matvec::StatDistBase::distname.
00045 {return distname;}
|
|
|
Definition at line 176 of file statdist.h. References nc_value.
00176 {return nc_value;}
|
|
||||||||||||
|
Definition at line 58 of file statdistbase.h.
00058 {std::cerr << "error\n"; return 0.0;}
|
|
||||||||||||
|
Definition at line 376 of file statdist.cpp.
00381 {
00382 if (nc_value != 0.0) throw exception("ChiSquareDist::mgf(): not available yet: noncentrality");
00383 if (t >= 0.5) throw exception("ChiSquareDist::mgf(t): t must be < 1/2");
00384 return 1.0/pow(1.0-2.0*t,df_value/2.0);
00385 }
00386
00387 double ChiSquareDist::nonct(const double cv,const double p) const
00388 {
00389 if (p<0.0 || p>1.0) throw exception("ChiSquareDist::nonct(): bad arg, value in (0,1) expected");
00390 int errcode = 0;
00391 double eps = 1.0e-6;
00392 double bot = 0.0;
00393 double top = df_value + 26000.0;
00394 double p2,ppt;
00395 while (top-bot > eps) {
00396 ppt = (top + bot)*0.5;
00397 p2 = ChiSquare_cdf(cv,df_value,ppt,errcode);
00398 if (errcode != 0) break;
00399 if (p2 < p ) {
|
|
||||||||||||
|
Implements matvec::StatDistBase. Definition at line 464 of file statdist.cpp. References df_value.
00466 {
00467 par = nc_value;
00468 }
00469 else {
00470 throw exception("ChiSquareDist::parameter(): bad arg value, 1 or 2 expected");
00471 }
00472 return par;
00473 }
00474
00475 void ChiSquareDist::parameter(const int k,const double x)
00476 {
00477 if (k==1) {
00478 df_value = x;
00479 }
00480 else if (k==2) {
|
|
|
Implements matvec::StatDistBase. Definition at line 449 of file statdist.cpp.
00454 {
00455 doubleMatrix x(m,n);
00456 sample(x);
00457 return x;
00458 }
00459
00460 double ChiSquareDist::parameter(const int k) const
00461 {
00462 double par = 0.0;
|
|
|
The random variable X has a non-central
Implements matvec::StatDistBase. Definition at line 359 of file statdist.cpp. References nc_value.
00365 {\exp(-(x+\lambda)/2)}{2\frac{1}{2}r}
00366 \sum_{j=0}^\infty \frac{x^{r/2+j-1}\lambda^j}{\Gamma(r/2+j)2^{2j}j!},
00367 \quad 0 \leq x < \infty
|
|
||||||||||||
|
Definition at line 348 of file statdist.cpp. Referenced by ChiSquareDist().
00348 {
00349 throw exception("LogNormalDist::parameter(): bad arg 1");
00350 }
00351 }
00352
00353 /////////////////// ChiSquare class /////////////////////////////
|
|
||||||||||||
|
Implements matvec::StatDistBase. Definition at line 442 of file statdist.cpp.
00447 {
|
|
|
Implements matvec::StatDistBase. Definition at line 435 of file statdist.cpp.
00438 {
00439 for (i=0; i<nr; i++) {
00440 bot = x[i]; top = &bot[nc];
|
|
|
Implements matvec::StatDistBase. Definition at line 171 of file statdist.h. References df_value, and matvec::genchi().
|
|
|
Implements matvec::StatDistBase. Definition at line 414 of file statdist.cpp. References nc_value.
00417 {
00418 while (bot < top ) *bot++ = genchi(df);
00419 }
00420 else {
00421 while (bot < top ) *bot++ = gennch(df,nc_value);
00422 }
00423 }
00424
00425 void ChiSquareDist::sample(doubleMatrix& x) const
00426 {
00427 int nr = x.num_rows();
00428 int nc = x.num_cols();
00429 double *bot,*top;
00430 unsigned i;
00431 int df = static_cast<int>(df_value);
00432 if (nc_value == 0.0) {
00433 for (i=0; i<nr; i++) {
|
|
|
Implements matvec::StatDistBase. Definition at line 401 of file statdist.cpp.
00402 {
00403 bot = ppt;
00404 }
00405 else {
00406 break;
00407 }
00408 }
00409 return ppt;
00410 }
00411
00412 void ChiSquareDist::sample(Vector<double>& x) const
|
|
|
Implements matvec::StatDistBase. Definition at line 175 of file statdist.h. References df_value, and nc_value.
|
|
|
Definition at line 159 of file statdist.h. Referenced by cdf(), display(), inv(), mean(), mgf(), parameter(), sample(), and variance(). |
|
|
|
Definition at line 159 of file statdist.h. Referenced by cdf(), display(), inv(), mean(), mgf(), nonc(), pdf(), sample(), and variance(). |
1.2.16