NEST  2.6.0,not_revisioned_source_dir@0
exp_randomdev.h
Go to the documentation of this file.
1 /*
2  * exp_randomdev.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef EXP_RANDOMDEV_H
24 #define EXP_RANDOMDEV_H
25 
26 #include <cmath>
27 #include "randomgen.h"
28 #include "randomdev.h"
29 #include "lockptr.h"
30 
31 namespace librandom {
32 
33 /*BeginDocumentation
34 Name: rdevdict::exponential - exponential random deviate generator
35 Description: Generates exponentially distributed random numbers.
36 
37  p(x) = lambda exp(-lambda*x), x >= 0.
38 
39 Parameters:
40  lambda - rate parameter (default: 1.0)
41 
42 SeeAlso: CreateRDV, RandomArray, rdevdict
43 Author: Hans Ekkehard Plesser
44 */
45 
52  class ExpRandomDev : public RandomDev
53  {
54 
55  public:
56 
57  // accept only lockPTRs for initialization,
58  // otherwise creation of a lock ptr would
59  // occur as side effect---might be unhealthy
60  ExpRandomDev(RngPtr r_in) : RandomDev(r_in), lambda_(1.0) {}
61  ExpRandomDev() : RandomDev(), lambda_(1.0) {} // threaded
62 
63  using RandomDev::operator();
64  double operator()(RngPtr rthrd) const; // threaded
65 
67  void set_status(const DictionaryDatum&);
68 
70  void get_status(DictionaryDatum&) const;
71 
72  private:
73  double lambda_;
74  };
75 
76  inline
77  double ExpRandomDev::operator()(RngPtr rthrd) const
78  {
79  return -std::log(rthrd->drandpos()) / lambda_;
80  }
81 
82 }
83 
84 # endif
virtual double operator()(void)
Operator delivering doubles.
Definition: randomdev.h:199
void set_status(const DictionaryDatum &)
set distribution parameters from SLI dict
Definition: exp_randomdev.cpp:26
double lambda_
rate parameter
Definition: exp_randomdev.h:73
Abstract base class for access to non-uniform random deviate generators.
Definition: randomdev.h:131
ExpRandomDev()
Definition: exp_randomdev.h:61
ExpRandomDev(RngPtr r_in)
Definition: exp_randomdev.h:60
void get_status(DictionaryDatum &) const
get distribution parameters from SLI dict
Definition: exp_randomdev.cpp:38
Class ExpRandomDev Create exponential random numbers.
Definition: exp_randomdev.h:52