Skip to content

Commit

Permalink
Add seed to lfmcmc run function (#30)
Browse files Browse the repository at this point in the history
* Add seed param to lfmcmc run function

* Remove default param in lfmcmc-meat.hpp

* Bumping version number

* Make single header
  • Loading branch information
apulsipher authored Nov 4, 2024
1 parent 884f49c commit 3ebd187
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
14 changes: 10 additions & 4 deletions epiworld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* Versioning */
#define EPIWORLD_VERSION_MAJOR 0
#define EPIWORLD_VERSION_MINOR 4
#define EPIWORLD_VERSION_PATCH 1
#define EPIWORLD_VERSION_PATCH 2

static const int epiworld_version_major = EPIWORLD_VERSION_MAJOR;
static const int epiworld_version_minor = EPIWORLD_VERSION_MINOR;
Expand Down Expand Up @@ -1249,7 +1249,8 @@ class LFMCMC {
void run(
std::vector< epiworld_double > param_init,
size_t n_samples_,
epiworld_double epsilon_
epiworld_double epsilon_,
int seed = -1
);

LFMCMC() {};
Expand Down Expand Up @@ -1526,7 +1527,8 @@ class LFMCMC {
void run(
std::vector< epiworld_double > param_init,
size_t n_samples_,
epiworld_double epsilon_
epiworld_double epsilon_,
int seed = -1
);

LFMCMC() {};
Expand Down Expand Up @@ -1796,7 +1798,8 @@ template<typename TData>
inline void LFMCMC<TData>::run(
std::vector< epiworld_double > params_init_,
size_t n_samples_,
epiworld_double epsilon_
epiworld_double epsilon_,
int seed
)
{

Expand All @@ -1809,6 +1812,9 @@ inline void LFMCMC<TData>::run(
params_init = params_init_;
n_parameters = params_init_.size();

if (seed >= 0)
this->seed(seed);

params_now.resize(n_parameters);
params_prev.resize(n_parameters);

Expand Down
2 changes: 1 addition & 1 deletion include/epiworld/epiworld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* Versioning */
#define EPIWORLD_VERSION_MAJOR 0
#define EPIWORLD_VERSION_MINOR 4
#define EPIWORLD_VERSION_PATCH 1
#define EPIWORLD_VERSION_PATCH 2

static const int epiworld_version_major = EPIWORLD_VERSION_MAJOR;
static const int epiworld_version_minor = EPIWORLD_VERSION_MINOR;
Expand Down
3 changes: 2 additions & 1 deletion include/epiworld/math/lfmcmc/lfmcmc-bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class LFMCMC {
void run(
std::vector< epiworld_double > param_init,
size_t n_samples_,
epiworld_double epsilon_
epiworld_double epsilon_,
int seed = -1
);

LFMCMC() {};
Expand Down
6 changes: 5 additions & 1 deletion include/epiworld/math/lfmcmc/lfmcmc-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ template<typename TData>
inline void LFMCMC<TData>::run(
std::vector< epiworld_double > params_init_,
size_t n_samples_,
epiworld_double epsilon_
epiworld_double epsilon_,
int seed
)
{

Expand All @@ -218,6 +219,9 @@ inline void LFMCMC<TData>::run(
params_init = params_init_;
n_parameters = params_init_.size();

if (seed >= 0)
this->seed(seed);

params_now.resize(n_parameters);
params_prev.resize(n_parameters);

Expand Down

0 comments on commit 3ebd187

Please sign in to comment.