mc_reject
Header file for the Monte Carlo Rejection Sampler
Functions
-
class mcr_sampler
- #include <mc_reject.h>
Public Functions
-
mcr_sampler(void (*probability)(double *prob, void *parameters, int d, int threadid), void (*draw_parameters)(void *prop_parameters, int d, int threadid, gsl_rng *r), int dimension, double *param_ranges_max, double *param_ranges_min)
Class constructor for Monte Carlo Rejection Sampler.
Assumes no parallel threading
`probability’ is the function that should return the probability of a given sample
`draw_parameters’ — NULL, if default should be used. Otherwise, this should propose another parameter set
param_ranges_max/min are only used if the default draw_parameter is used, otherwise can be NULL
- Parameters:
dimension – Dimension
param_ranges_max – Max allowed parameters — Shape [dimension]
param_ranges_min – Min allowed parameters — Shape [dimension]
-
mcr_sampler(void (*probability)(double *prob, void *parameters, int d, int threadid), void (*draw_parameters)(void *prop_parameters, int d, int threadid, gsl_rng *r), int dimension, double *param_ranges_max, double *param_ranges_min, int thread_num, bool thread_safe)
Class constructor for Monte Carlo Rejection Sampler.
Allows parallel threading
`probability’ is the function that should return the probability of a given sample
`draw_parameters’ — NULL, if default should be used. Otherwise, this should propose another parameter set
param_ranges_max/min are only used if the default draw_parameter is used, otherwise can be NULL
- Parameters:
dimension – Dimension
param_ranges_max – Max allowed parameters — Shape [dimension]
param_ranges_min – Min allowed parameters — Shape [dimension]
thread_num – Thread number to use
thread_safe – Bool thread safe — true if parallel threading should be used
-
~mcr_sampler()
Destructor function for mcr_sampler.
Deallocates the gsl_rng memory
-
void sample_distribution(int N_samples, void **output)
Main driver — Samples from distribution that has been associated with a sampler object.
- Parameters:
output – [out] Output array shape [N_samples][dimension] Caste to void **
-
void sample(void *output, int threadid)
Internal routine to return one accepted sample.
Should not be used directly by user — couldn’t make private though
- Parameters:
output – [out] Output, accepted parameter set
threadid – Thread id — not currently used, but included for future proofing
Public Members
-
bool thread_safe
-
int thread_num
-
int dimension
-
int parallel_job_num
-
double *param_ranges_max
-
double *param_ranges_min
-
double **samples
Private Functions
-
void draw_param_standard(void *prop_params, int d, int threadid, gsl_rng *r)
Standard option to draw samples randomly.
Assumes the parameter vector is of type double *
Uses the ranges provided by the user to randomly draw samples uniformly
- Parameters:
prop_params – [out] Proposed Param
d – Dimension of parameter space
threadid – Thread ID for parallel execution
r – GSL random number seed
-
void init(void (*probability)(double *prob, void *parameters, int d, int threadid), void (*draw_parameters)(void *prop_parameters, int d, int threadid, gsl_rng *r), int dimension, double *param_ranges_max, double *param_ranges_min, int thread_num, bool thread_safe)
-
mcr_sampler(void (*probability)(double *prob, void *parameters, int d, int threadid), void (*draw_parameters)(void *prop_parameters, int d, int threadid, gsl_rng *r), int dimension, double *param_ranges_max, double *param_ranges_min)
-
struct mcr_job
- #include <mc_reject.h>