NEURON
LogNorm.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 _LogNormal_h
19 #ifdef __GNUG__
20 //#pragma interface
21 #endif
22 #define _LogNormal_h
23 
24 #include <Normal.h>
25 
26 class LogNormal: public Normal {
27 protected:
28  double logMean;
29  double logVariance;
30  void setState();
31 public:
32  LogNormal(double mean, double variance, RNG *gen);
33  double mean();
34  double mean(double x);
35  double variance();
36  double variance(double x);
37  virtual double operator()();
38 };
39 
40 
41 inline void LogNormal::setState()
42 {
43  double m2 = logMean * logMean;
44  pMean = log(m2 / sqrt(logVariance + m2) );
45 // from ch@heike.informatik.uni-dortmund.de:
46 // (was pVariance = log((sqrt(logVariance + m2)/m2 )); )
47  pStdDev = sqrt(log((logVariance + m2)/m2 ));
48 }
49 
50 inline LogNormal::LogNormal(double mean, double variance, RNG *gen)
51  : Normal(mean, variance, gen)
52 {
53  logMean = mean;
55  setState();
56 }
57 
58 inline double LogNormal::mean() {
59  return logMean;
60 }
61 
62 inline double LogNormal::mean(double x)
63 {
64  double t=logMean; logMean = x; setState();
65  return t;
66 }
67 
68 inline double LogNormal::variance() {
69  return logVariance;
70 }
71 
72 inline double LogNormal::variance(double x)
73 {
74  double t=logVariance; logVariance = x; setState();
75  return t;
76 }
77 
78 #endif
virtual double operator()()
Definition: LogNorm.cpp:35
double logVariance
Definition: LogNorm.h:29
LogNormal(double mean, double variance, RNG *gen)
Definition: LogNorm.h:50
double mean()
Definition: LogNorm.h:58
double logMean
Definition: LogNorm.h:28
void setState()
Definition: LogNorm.h:41
double variance()
Definition: LogNorm.h:68
Definition: Normal.h:26
double pMean
Definition: Normal.h:31
double pStdDev
Definition: Normal.h:33
Definition: RNG.h:55
double t
Definition: cvodeobj.cpp:59
sqrt
Definition: extdef.h:3
log
Definition: extdef.h:4