blitz Version 1.0.2
Loading...
Searching...
No Matches
chisquare.h
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id$
3
4/*
5 * Chi^2 distribution
6 *
7 * This code has been adapted from RANDLIB.C 1.3, by
8 * Barry W. Brown, James Lovato, Kathy Russell, and John Venier.
9 * Code was originally by Ahrens and Dieter (see above).
10 *
11 * Adapter's notes:
12 */
13
14#ifndef BZ_RANDOM_CHISQUARE
15#define BZ_RANDOM_CHISQUARE
16
17#ifndef BZ_RANDOM_GAMMA
18 #include <random/gamma.h>
19#endif
20
21namespace ranlib {
22
23template<typename T = double, typename IRNG = defaultIRNG,
24 typename stateTag = defaultState>
25class ChiSquare : public Gamma<T,IRNG,stateTag>
26{
27public:
28 typedef T T_numtype;
29
31 : Gamma<T,IRNG,stateTag>(df/2.0) // isn't this redundant with setDF call?
32 {
33 setDF(df);
34 }
35
36 ChiSquare(T df, unsigned int i)
37 : Gamma<T,IRNG,stateTag>(df/2.0, i)
38 {
39 setDF(df);
40 }
41
42 void setDF(T _df)
43 {
44 BZPRECONDITION(_df > 0.0);
45 df = _df;
47 }
48
50 {
51 return 2.0 * sgamma();
52 }
53
54protected:
56 {
58 }
59
60 T df;
61};
62
63}
64
65#endif // BZ_RANDOM_CHISQUARE
ChiSquare(T df)
Definition chisquare.h:30
T T_numtype
Definition chisquare.h:28
void setDF(T _df)
Definition chisquare.h:42
T random()
Definition chisquare.h:49
T df
Definition chisquare.h:60
ChiSquare(T df, unsigned int i)
Definition chisquare.h:36
T sgamma()
Definition chisquare.h:55
void setMean(T mean)
Definition gamma.h:74
T random()
Definition gamma.h:113
Definition beta.h:50
sharedState defaultState
Definition default.h:55
MersenneTwister defaultIRNG
Definition default.h:120