Permalink
Browse files

Fixed a minor casting bug in random stream implementation and renamed…

… the streams to camel case
  • Loading branch information...
1 parent efd4de9 commit 4a9f959add0d78d72dc8780eeb1853ba9ffa77ef @miscco committed Sep 26, 2016
Showing with 15 additions and 15 deletions.
  1. +2 −2 Cortical_Column.cpp
  2. +1 −1 Cortical_Column.h
  3. +7 −7 Random_Stream.h
  4. +2 −2 Stimulation.h
  5. +2 −2 Thalamic_Column.cpp
  6. +1 −1 Thalamic_Column.h
View
@@ -48,10 +48,10 @@ void Cortical_Column::set_RNG(void) {
Rand_vars.reserve(2*numRandomVariables);
for (unsigned i=0; i < numRandomVariables; ++i){
/* Add the RNG for I_{l}*/
- MTRands.push_back(random_stream_normal(0.0, dphi*dt));
+ MTRands.push_back(randomStreamNormal(0.0, dphi*dt));
/* Add the RNG for I_{l,0} */
- MTRands.push_back(random_stream_normal(0.0, dt));
+ MTRands.push_back(randomStreamNormal(0.0, dt));
/* Get the random number for the first iteration */
Rand_vars.push_back(MTRands[2*i]());
View
@@ -170,7 +170,7 @@ class Cortical_Column {
const std::vector<double> B = {0.75, 0.75, 0.0, 0.0};
/* Random number generators */
- std::vector<random_stream_normal> MTRands;
+ std::vector<randomStreamNormal> MTRands;
/* Container for noise */
std::vector<double> Rand_vars;
View
@@ -29,11 +29,11 @@
#pragma once
#include <random>
-class random_stream_normal {
+class randomStreamNormal {
public:
- explicit random_stream_normal(double mean, double stddev)
+ explicit randomStreamNormal(double mean, double stddev)
: mt(rand()), norm_dist(mean, stddev) {}
- explicit random_stream_normal(double mean, double stddev, double seed)
+ explicit randomStreamNormal(double mean, double stddev, double seed)
: mt(seed), norm_dist(mean, stddev) {}
double operator ()(void) { return norm_dist(mt); }
@@ -42,14 +42,14 @@ class random_stream_normal {
std::normal_distribution<double> norm_dist;
};
-class random_stream_uniform_int {
+class randomStreamUniformInt {
public:
- explicit random_stream_uniform_int(int lower_bound, int upper_bound)
+ explicit randomStreamUniformInt(int lower_bound, int upper_bound)
: mt(rand()), uniform_dist(lower_bound, upper_bound) {}
- explicit random_stream_uniform_int(int lower_bound, int upper_bound, double seed)
+ explicit randomStreamUniformInt(int lower_bound, int upper_bound, double seed)
: mt(seed), uniform_dist(lower_bound, upper_bound) {}
- double operator ()(void) { return uniform_dist(mt); }
+ int operator ()(void) { return uniform_dist(mt); }
private:
std::mt19937_64 mt;
std::uniform_int_distribution<> uniform_dist;
View
@@ -141,7 +141,7 @@ class Stim {
std::vector<int> marker_stimulation;
/* Random number generator in case of semi-periodic stimulation */
- random_stream_uniform_int Uniform_Distribution = random_stream_uniform_int(0, 0);
+ randomStreamUniformInt Uniform_Distribution = randomStreamUniformInt(0, 0);
/* Create MATLAB container for marker storage */
friend mxArray* get_marker(Stim &stim);
@@ -190,7 +190,7 @@ void Stim::setup (double* var_stim) {
/* If ISI is random create RNG */
if (ISI_range != 0){
/* Generate uniform distribution */
- Uniform_Distribution = random_stream_uniform_int(ISI-ISI_range, ISI+ISI_range);
+ Uniform_Distribution = randomStreamUniformInt(ISI-ISI_range, ISI+ISI_range);
}
} else {
/* In case of phase dependent stimulation, time_to_stim is the time from minimum detection to start of stimulation */
View
@@ -44,10 +44,10 @@ void Thalamic_Column::set_RNG(void) {
Rand_vars.reserve(2*numRandomVariables);
for (unsigned i=0; i < numRandomVariables; ++i){
/* Add the RNG for I_{l}*/
- MTRands.push_back(random_stream_normal(0.0, dphi*dt));
+ MTRands.push_back(randomStreamNormal(0.0, dphi*dt));
/* Add the RNG for I_{l,0} */
- MTRands.push_back(random_stream_normal(0.0, dt));
+ MTRands.push_back(randomStreamNormal(0.0, dt));
/* Get the random number for the first iteration */
Rand_vars.push_back(MTRands[2*i]());
View
@@ -214,7 +214,7 @@ class Thalamic_Column {
const std::vector<double> B = {0.75, 0.75, 0.0, 0.0};
/* Random number generators */
- std::vector<random_stream_normal> MTRands;
+ std::vector<randomStreamNormal> MTRands;
/* Container for noise */
std::vector<double> Rand_vars;

0 comments on commit 4a9f959

Please sign in to comment.