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

Definition at line 487 of file statdist.h.
Public Methods | |
| NegativeBinomialDist (const long n, const double p) | |
| NegativeBinomialDist (const NegativeBinomialDist &u) | |
| void | display (void) const |
| void | reset (const long n, const double p) |
| 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 | pdf (const double x) const |
| double | cdf (const double x) const |
| double | pdf (const long k) const |
| double | cdf (const long k) const |
| double | mgf (const double t) const |
| double | inv (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 | |
| long | n_value |
| double | p_value |
| std::string | distname |
|
||||||||||||
|
Definition at line 492 of file statdist.h. References matvec::StatDistBase::distname, and reset().
|
|
|
Definition at line 494 of file statdist.h. References matvec::StatDistBase::distname, and reset().
00494 :StatDistBase() 00495 {distname="NegativeBinomialDist"; 00496 reset(u.n_value,u.p_value);} |
|
|
Pr(X <= k) = sum{NegativeBinomial(n,p)), over x=0,1,...k} Definition at line 1460 of file statdist.cpp.
01465 {x+n-1)!}{x!(n-1)!}p^n(1-p)^x, \quad x = 0,1,2,\ldots,
|
|
|
Implements matvec::StatDistBase. Definition at line 510 of file statdist.h.
00510 {return cdf(long(x));}
|
|
|
Implements matvec::StatDistBase. Definition at line 498 of file statdist.h. References matvec::StatDistBase::distname, n_value, and p_value.
|
|
|
Implements matvec::StatDistBase. Definition at line 514 of file statdist.h.
00515 {std::cerr << " NegativeBinomialDist::inv(): not available\n"; return p;}
|
|
|
Implements matvec::StatDistBase. Definition at line 506 of file statdist.h. References n_value, and p_value.
|
|
|
Implements matvec::StatDistBase. Definition at line 1467 of file statdist.cpp. References matvec::gammln().
|
|
|
Definition at line 45 of file statdistbase.h. References matvec::StatDistBase::distname.
00045 {return distname;}
|
|
||||||||||||
|
Definition at line 58 of file statdistbase.h.
00058 {std::cerr << "error\n"; return 0.0;}
|
|
||||||||||||
|
Implements matvec::StatDistBase. Definition at line 1534 of file statdist.cpp. References sample().
01536 {
01537 doubleMatrix x(m,n);
01538 sample(x);
01539 return x;
01540 }
01541
01542 double NegativeBinomialDist::parameter(const int k) const
01543 {
01544 double retval = 0.0;
01545 if (k==1) {
01546 retval = static_cast<double>(n_value);
01547 }
01548 else if (k==2) {
01549 retval = p_value;
01550 }
01551 else {
01552 throw exception("NegativeBinomialDist::parameter(): bad arg, 1 or 2 expected");
01553 }
01554 return retval;
01555 }
|
|
|
Implements matvec::StatDistBase. Definition at line 1519 of file statdist.cpp.
01522 {
01523 bot = x[i]; top = &bot[nc];
01524 while (bot < top ) *bot++ = sample();
01525 }
01526 }
01527
01528 Vector<double> NegativeBinomialDist::sample(unsigned n) const
01529 {
01530 Vector<double> x(n);
01531 sample(x);
01532 return x;
|
|
|
The random variable X has a negative binomial distribution if its probability density function (pdf) is defined by
Definition at line 1445 of file statdist.cpp.
01448 {
01449 if (k != 1) throw exception("GeometricDist::parameter(): bad arg1");
01450 if (x <= 0.0 || x >= 1.0) throw exception("GeometricDist::parameter(): bad arg2");
01451 p_value = x;
01452 }
01453
01454 /////////////////// NegativeBinomialDist class //////////////////////
01455 void NegativeBinomialDist::reset(const long n,const double p)
|
|
|
Implements matvec::StatDistBase. Definition at line 509 of file statdist.h.
00509 {return pdf(long(x));}
|
|
||||||||||||
|
Definition at line 1434 of file statdist.cpp. References sample(). Referenced by NegativeBinomialDist().
01435 {
01436 doubleMatrix x(m,n);
01437 sample(x);
01438 return x;
01439 }
|
|
||||||||||||
|
Implements matvec::StatDistBase. Definition at line 1512 of file statdist.cpp.
01517 {
|
|
|
Implements matvec::StatDistBase. Definition at line 1505 of file statdist.cpp.
01509 {
01510 double tmp = std::log(1.0-p_value);
|
|
|
Implements matvec::StatDistBase. Definition at line 1475 of file statdist.cpp. References p_value. Referenced by parameter(), and reset().
01481 {NegativeBinomial(n,p)), over x=0,1,...k}
01482 */
01483 double NegativeBinomialDist::cdf(const long k) const
|
|
|
Implements matvec::StatDistBase. Definition at line 1493 of file statdist.cpp. References n_value, and p_value.
|
|
|
Implements matvec::StatDistBase. Definition at line 1485 of file statdist.cpp.
01491 {
|
|
|
Implements matvec::StatDistBase. Definition at line 507 of file statdist.h. References n_value, and p_value.
|
|
|
|
Definition at line 489 of file statdist.h. |
|
|
Definition at line 490 of file statdist.h. |
1.2.16