Skip to content

Commit

Permalink
Fixed minor casting bug in random stream and renamed them to camel case
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Sep 26, 2016
1 parent 314de67 commit b2697bd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cortex_mex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <iterator>
#include <vector>

#include "Cortical_Column.h"
#include "Data_Storage.h"
#include "Stimulation.h"
mxArray* SetMexArray(int N, int M);
Expand Down
6 changes: 2 additions & 4 deletions Cortical_Column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,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]());
Expand All @@ -67,12 +67,10 @@ double Cortical_Column::noise_aRK(int M) const{
/******************************************************************************/
/* Firing Rate functions */
/******************************************************************************/
/* Pyramidal firing rate */
double Cortical_Column::get_Qp (int N) const{
return Qp_max / (1 + exp(-C1 * (Vp[N] - theta_p) / sigma_p));
}

/* Inhibitory firing rate */
double Cortical_Column::get_Qi (int N) const{
return Qi_max / (1 + exp(-C1 * (Vi[N] - theta_i) / sigma_i));
}
Expand Down
2 changes: 1 addition & 1 deletion Cortical_Column.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Cortical_Column {
{var[0] = (-3*var[0] + 2*var[1] + 4*var[2] + 2*var[3] + var[4])/6 + noise_aRK(noise);}

/* Random number generators */
std::vector<random_stream_normal> MTRands;
std::vector<randomStreamNormal> MTRands;

/* Container for noise */
std::vector<double> Rand_vars;
Expand Down
14 changes: 7 additions & 7 deletions Random_Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Stimulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,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);
Expand Down Expand Up @@ -167,7 +167,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
Expand Down

0 comments on commit b2697bd

Please sign in to comment.