PetaVision  Alpha
GaussianRandom.hpp
1 /*
2  * GaussianRandom.hpp
3  *
4  * Created on: Aug 23, 2013
5  * Author: pschultz
6  */
7 
8 #ifndef GAUSSIANRANDOM_HPP_
9 #define GAUSSIANRANDOM_HPP_
10 
11 #include "Random.hpp"
12 #include <vector>
13 
15  bool hasHeldValue;
16  float heldValue;
17 };
18 
19 namespace PV {
20 
21 class GaussianRandom : public PV::Random {
22  public:
23  GaussianRandom(int count);
24  GaussianRandom(const PVLayerLoc *locptr, bool isExtended);
25  virtual ~GaussianRandom();
26 
27  float gaussianDist(int localIndex = 0);
28  float gaussianDist(int localIndex, float mean, float sigma) {
29  return mean + gaussianDist(localIndex) * sigma;
30  }
31  void gaussianDist(float *values, int localIndex, int count = 1) {
32  for (int k = 0; k < count; k++)
33  values[k] = gaussianDist(localIndex + k);
34  }
35  void gaussianDist(float *values, int localIndex, int count, float mean, float sigma) {
36  for (int k = 0; k < count; k++)
37  values[k] = gaussianDist(localIndex + k, mean, sigma);
38  }
39 
40  protected:
42  int initializeFromCount(unsigned int count);
43  int initializeFromLoc(const PVLayerLoc *locptr, bool isExtended);
44  int initializeGaussian();
45 
46  private:
47  int initialize_base();
48 
49  // Member variables
50  protected:
51  std::vector<box_muller_data> heldValues;
52 };
53 
54 } /* namespace PV */
55 #endif /* GAUSSIANRANDOM_HPP_ */