source: trunk/src/emx/include/Attic/cpp/Normal.h@ 18

Last change on this file since 18 was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2/*
3Copyright (C) 1988 Free Software Foundation
4 written by Dirk Grunwald ([email protected])
5
6This file is part of the GNU C++ Library. This library is free
7software; you can redistribute it and/or modify it under the terms of
8the GNU Library General Public License as published by the Free
9Software Foundation; either version 2 of the License, or (at your
10option) any later version. This library is distributed in the hope
11that it will be useful, but WITHOUT ANY WARRANTY; without even the
12implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the GNU Library General Public License for more details.
14You should have received a copy of the GNU Library General Public
15License along with this library; if not, write to the Free Software
16Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18#ifndef _Normal_h
19#ifdef __GNUG__
20#pragma interface
21#endif
22#define _Normal_h
23
24#include <Random.h>
25
26class Normal: public Random {
27 char haveCachedNormal;
28 double cachedNormal;
29
30protected:
31 double pMean;
32 double pVariance;
33 double pStdDev;
34
35public:
36 Normal(double xmean, double xvariance, RNG *gen);
37 double mean();
38 double mean(double x);
39 double variance();
40 double variance(double x);
41 virtual double operator()();
42};
43
44
45inline Normal::Normal(double xmean, double xvariance, RNG *gen)
46: Random(gen) {
47 pMean = xmean;
48 pVariance = xvariance;
49 pStdDev = sqrt(pVariance);
50 haveCachedNormal = 0;
51}
52
53inline double Normal::mean() { return pMean; };
54inline double Normal::mean(double x) {
55 double t=pMean; pMean = x;
56 return t;
57}
58
59inline double Normal::variance() { return pVariance; }
60inline double Normal::variance(double x) {
61 double t=pVariance; pVariance = x;
62 pStdDev = sqrt(pVariance);
63 return t;
64};
65
66#endif
Note: See TracBrowser for help on using the repository browser.