NEURON
HypGeom.h
Go to the documentation of this file.
1
// This may look like C code, but it is really -*- C++ -*-
2
/*
3
Copyright (C) 1988 Free Software Foundation
4
written by Dirk Grunwald (grunwald@cs.uiuc.edu)
5
6
This file is part of the GNU C++ Library. This library is free
7
software; you can redistribute it and/or modify it under the terms of
8
the GNU Library General Public License as published by the Free
9
Software Foundation; either version 2 of the License, or (at your
10
option) any later version. This library is distributed in the hope
11
that it will be useful, but WITHOUT ANY WARRANTY; without even the
12
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13
PURPOSE. See the GNU Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
*/
18
#ifndef _HyperGeometric_h
19
#ifdef __GNUG__
20
//#pragma interface
21
#endif
22
#define _HyperGeometric_h
23
24
#include <
Random.h
>
25
26
class
HyperGeometric
:
public
Random
{
27
protected
:
28
double
pMean
;
29
double
pVariance
;
30
double
pP
;
31
void
setState
();
32
33
public
:
34
HyperGeometric
(
double
mean
,
double
variance
,
RNG
*gen);
35
36
double
mean
();
37
double
mean
(
double
x);
38
double
variance
();
39
double
variance
(
double
x);
40
41
virtual
double
operator()
();
42
};
43
44
45
inline
void
HyperGeometric::setState
() {
46
double
z =
pVariance
/ (
pMean
*
pMean
);
47
pP
= 0.5 * (1.0 -
sqrt
((z - 1.0) / ( z + 1.0 )));
48
}
49
50
inline
HyperGeometric::HyperGeometric
(
double
mean
,
double
variance
,
RNG
*gen)
51
:
Random
(gen) {
52
pMean
=
mean
;
pVariance
=
variance
;
53
setState
();
54
}
55
56
inline
double
HyperGeometric::mean
() {
return
pMean
; };
57
58
inline
double
HyperGeometric::mean
(
double
x) {
59
double
t
=
pMean
;
pMean
= x;
60
setState
();
return
t
;
61
}
62
63
inline
double
HyperGeometric::variance
() {
return
pVariance
; }
64
65
inline
double
HyperGeometric::variance
(
double
x) {
66
double
t
=
pVariance
;
pVariance
= x;
67
setState
();
return
t
;
68
}
69
70
#endif
HyperGeometric::variance
double variance()
Definition:
HypGeom.h:63
HyperGeometric::pVariance
double pVariance
Definition:
HypGeom.h:29
RNG
Definition:
RNG.h:55
Random
Definition:
Random.h:32
HyperGeometric::operator()
virtual double operator()()
Definition:
HypGeom.cpp:25
HyperGeometric::HyperGeometric
HyperGeometric(double mean, double variance, RNG *gen)
Definition:
HypGeom.h:50
HyperGeometric::pP
double pP
Definition:
HypGeom.h:30
HyperGeometric::setState
void setState()
Definition:
HypGeom.h:45
HyperGeometric::pMean
double pMean
Definition:
HypGeom.h:28
sqrt
sqrt
Definition:
extdef.h:3
HyperGeometric::mean
double mean()
Definition:
HypGeom.h:56
Random.h
HyperGeometric
Definition:
HypGeom.h:26
t
double t
Definition:
init.cpp:123
src
gnu
HypGeom.h