vSMC  v3.0.0
Scalable Monte Carlo
rng.h
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/rng/rng.h
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2016, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_RNG_RNG_H
33 #define VSMC_RNG_RNG_H
34 
35 #include <vsmc/internal/common.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
43 
46 int vsmc_rng_type_max();
47 
50 
52 vsmc_rng vsmc_rng_new(unsigned seed, vSMCRNGType type);
53 
55 void vsmc_rng_delete(vsmc_rng *rng_ptr);
56 
58 void vsmc_rng_assign(vsmc_rng rng, vsmc_rng other);
59 
61 void vsmc_rng_seed(vsmc_rng rng, unsigned seed);
62 
64 void vsmc_rng_discard(vsmc_rng rng, unsigned nskip);
65 
67 int vsmc_rng_is_eq(vsmc_rng rng1, vsmc_rng rng2);
68 
70 int vsmc_rng_is_neq(vsmc_rng rng1, vsmc_rng rng2);
71 
73 size_t vsmc_rng_save(vsmc_rng rng, void *mem);
74 
76 void vsmc_rng_load(vsmc_rng rng, void *mem);
77 
79 void vsmc_rng_save_f(vsmc_rng rng, const char *filename);
80 
82 void vsmc_rng_load_f(vsmc_rng rng, const char *filename);
83 
85 
88 
90 void vsmc_seed(vsmc_rng rng);
91 
93 unsigned vsmc_seed_get(void);
94 
96 void vsmc_seed_set(unsigned seed);
97 
99 void vsmc_seed_modulo(unsigned div, unsigned rem);
100 
102 size_t vsmc_seed_save(void *mem);
103 
105 void vsmc_seed_load(const void *mem);
106 
108 void vsmc_seed_save_f(const char *filename);
109 
111 void vsmc_seed_load_f(const char *filename);
112 
114 
117 
119 void vsmc_u01_trans_sorted(size_t n, const double *u01, double *r);
120 
122 void vsmc_u01_trans_stratified(size_t n, const double *u01, double *r);
123 
125 void vsmc_u01_trans_systematic(size_t n, const double *u01, double *r);
126 
128 void vsmc_u01_rand_sorted(vsmc_rng rng, size_t n, double *r);
129 
131 void vsmc_u01_rand_stratified(vsmc_rng rng, size_t n, double *r);
132 
134 void vsmc_u01_rand_systematic(vsmc_rng rng, size_t n, double *r);
135 
137 
140 
142 void vsmc_rand(vsmc_rng rng, size_t n, unsigned *r);
143 
145 void vsmc_rand_64(vsmc_rng rng, size_t n, unsigned long long *r);
146 
148 void vsmc_rand_bernoulli(vsmc_rng rng, size_t n, int *r, double p);
149 
151 void vsmc_rand_binomial(vsmc_rng rng, size_t n, int *r, int t, double p);
152 
155  vsmc_rng rng, size_t n, long long *r, long long t, double p);
156 
158 void vsmc_rand_discrete(vsmc_rng rng, size_t n, int *r, size_t m,
159  const double *weight, int normalized);
160 
162 void vsmc_rand_discrete_64(vsmc_rng rng, size_t n, long long *r, size_t m,
163  const double *weight, int normalized);
164 
166 void vsmc_rand_geometric(vsmc_rng rng, size_t n, int *r, double p);
167 
169 void vsmc_rand_geometric_64(vsmc_rng rng, size_t n, long long *r, double p);
170 
173  vsmc_rng rng, size_t n, int *r, int k, double p);
174 
177  vsmc_rng rng, size_t n, long long *r, long long k, double p);
178 
180 void vsmc_rand_poisson(vsmc_rng rng, size_t n, int *r, double mean);
181 
183 void vsmc_rand_poisson_64(vsmc_rng rng, size_t n, long long *r, double mean);
184 
186 void vsmc_rand_uniform_int(vsmc_rng rng, size_t n, int *r, int a, int b);
187 
190  vsmc_rng rng, size_t n, long long *r, long long a, long long b);
191 
193 void vsmc_rand_arcsine(
194  vsmc_rng rng, size_t n, double *r, double alpha, double beta);
195 
197 void vsmc_rand_beta(
198  vsmc_rng rng, size_t n, double *r, double alpha, double beta);
199 
201 void vsmc_rand_cauchy(vsmc_rng rng, size_t n, double *r, double a, double b);
202 
204 void vsmc_rand_chi_squared(vsmc_rng rng, size_t n, double *r, double df);
205 
207 void vsmc_rand_exponential(vsmc_rng rng, size_t n, double *r, double lambda);
208 
211  vsmc_rng rng, size_t n, double *r, double a, double b);
212 
214 void vsmc_rand_fisher_f(
215  vsmc_rng rng, size_t n, double *r, double df1, double df2);
216 
218 void vsmc_rand_gamma(
219  vsmc_rng rng, size_t n, double *r, double alpha, double beta);
220 
222 void vsmc_rand_laplace(vsmc_rng rng, size_t n, double *r, double a, double b);
223 
225 void vsmc_rand_levy(vsmc_rng rng, size_t n, double *r, double a, double b);
226 
228 void vsmc_rand_logistic(vsmc_rng rng, size_t n, double *r, double a, double b);
229 
232  vsmc_rng rng, size_t n, double *r, double m, double s);
233 
235 void vsmc_rand_normal(
236  vsmc_rng rng, size_t n, double *r, double mean, double stddev);
237 
239 void vsmc_rand_normal_mv(vsmc_rng rng, size_t n, double *r, size_t dim,
240  const double *mean, const double *chol);
241 
243 void vsmc_rand_pareto(vsmc_rng rng, size_t n, double *r, double a, double b);
244 
246 void vsmc_rand_rayleigh(vsmc_rng rng, size_t n, double *r, double b);
247 
249 void vsmc_rand_student_t(vsmc_rng rng, size_t n, double *r, double df);
250 
252 void vsmc_rand_u01(vsmc_rng rng, size_t n, double *r);
253 
255 void vsmc_rand_u01_cc(vsmc_rng rng, size_t n, double *r);
256 
258 void vsmc_rand_u01_co(vsmc_rng rng, size_t n, double *r);
259 
261 void vsmc_rand_u01_oc(vsmc_rng rng, size_t n, double *r);
262 
264 void vsmc_rand_u01_oo(vsmc_rng rng, size_t n, double *r);
265 
268  vsmc_rng rng, size_t n, double *r, double a, double b);
269 
271 void vsmc_rand_weibull(vsmc_rng rng, size_t n, double *r, double a, double b);
272 
274 
277 
279 int vsmc_mkl_brng(vSMCRNGType type);
280 
282 
283 #ifdef __cplusplus
284 } // extern "C"
285 #endif
286 
287 #endif // VSMC_RNG_RNG_H
void vsmc_seed_modulo(unsigned div, unsigned rem)
vsmc::Seed::modulo
unsigned vsmc_seed_get(void)
vsmc::Seed::get
void vsmc_rand_beta(vsmc_rng rng, size_t n, double *r, double alpha, double beta)
vsmc::beta_distribution<double>
void vsmc_rand_gamma(vsmc_rng rng, size_t n, double *r, double alpha, double beta)
vsmc::gamma_distribution<double>
void vsmc_rand_discrete(vsmc_rng rng, size_t n, int *r, size_t m, const double *weight, int normalized)
vsmc::DiscreteDistribution<int>
void vsmc_rand_pareto(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::pareto_distribution<double>
void vsmc_rng_seed(vsmc_rng rng, unsigned seed)
RNGType::seed
void vsmc_rng_load_f(vsmc_rng rng, const char *filename)
RNGType::operator>> directly from an external file*/
void vsmc_rand_discrete_64(vsmc_rng rng, size_t n, long long *r, size_t m, const double *weight, int normalized)
vsmc::DiscreteDistribution<long long>
void vsmc_u01_trans_systematic(size_t n, const double *u01, double *r)
vsmc::u01_trans_systematic
void vsmc_rand_geometric_64(vsmc_rng rng, size_t n, long long *r, double p)
std::geometric_distribution<long long>
int vsmc_mkl_brng(vSMCRNGType type)
vsmc::mkl_brng
void vsmc_rand_u01_cc(vsmc_rng rng, size_t n, double *r)
vsmc::u01_cc_distribution<double>
void vsmc_rand_negative_binomial(vsmc_rng rng, size_t n, int *r, int k, double p)
std::negative_binomial_distribution<int>
void vsmc_rand_uniform_int(vsmc_rng rng, size_t n, int *r, int a, int b)
std::uniform_int_distribution<long long>
void vsmc_seed(vsmc_rng rng)
vsmc::Seed::operator()
void vsmc_rand_binomial_64(vsmc_rng rng, size_t n, long long *r, long long t, double p)
std::binomial_distribution<long long>
void vsmc_seed_set(unsigned seed)
vsmc::Seed::set
int vsmc_rng_is_neq(vsmc_rng rng1, vsmc_rng rng2)
RNGType::operator!=
vsmc_rng vsmc_rng_new(unsigned seed, vSMCRNGType type)
RNGType::RNGType
void vsmc_rand_student_t(vsmc_rng rng, size_t n, double *r, double df)
vsmc::student_t_distribution<double>
int vsmc_rng_type_check(vSMCRNGType type)
Check if a given RNGType is defined within the library.
void vsmc_rng_assign(vsmc_rng rng, vsmc_rng other)
RNGType::operator=
int vsmc_rng_is_eq(vsmc_rng rng1, vsmc_rng rng2)
RNGType::operator==
void vsmc_rand_normal_mv(vsmc_rng rng, size_t n, double *r, size_t dim, const double *mean, const double *chol)
vsmc::normal_mv_distribution<double>
void vsmc_rand_uniform_real(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::uniform_real_distribution<double>
void vsmc_u01_trans_sorted(size_t n, const double *u01, double *r)
vsmc::u01_trans_sorted
void vsmc_seed_load_f(const char *filename)
vsmc::Seed::operator>> directly from an external file
void vsmc_u01_trans_stratified(size_t n, const double *u01, double *r)
vsmc::u01_trans_stratifed
void vsmc_rand_geometric(vsmc_rng rng, size_t n, int *r, double p)
std::geometric_distribution<int>
void vsmc_rand_weibull(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::weibull_distribution<double>
void vsmc_u01_rand_sorted(vsmc_rng rng, size_t n, double *r)
vsmc::u01_rand_sorted
RealType u01(UIntType u) noexcept
Convert uniform unsigned integers to floating points within [0, 1].
Definition: u01.hpp:213
void vsmc_rng_save_f(vsmc_rng rng, const char *filename)
RNGType::operator<< directly to an external file
size_t vsmc_rng_save(vsmc_rng rng, void *mem)
RNGType::operator<<
void vsmc_rand_64(vsmc_rng rng, size_t n, unsigned long long *r)
vsmc::uniform_bits_distribution
void vsmc_rand_u01(vsmc_rng rng, size_t n, double *r)
vsmc::u01_distribution<double>
size_t vsmc_seed_save(void *mem)
vsmc::Seed::operator<<
void vsmc_rng_discard(vsmc_rng rng, unsigned nskip)
RNGType::discard
void vsmc_rand_negative_binomial_64(vsmc_rng rng, size_t n, long long *r, long long k, double p)
std::negative_binomial_distribution<long long>
void vsmc_rand_rayleigh(vsmc_rng rng, size_t n, double *r, double b)
vsmc::rayleigh_distribution<double>
void vsmc_rand_poisson_64(vsmc_rng rng, size_t n, long long *r, double mean)
std::poisson_distribution<long long>
void vsmc_rng_delete(vsmc_rng *rng_ptr)
RNGType::~RNGType
void div(std::size_t n, const float *a, const float *b, float *y)
Definition: vmath.hpp:95
void vsmc_seed_save_f(const char *filename)
vsmc::Seed::operator<< directly to an external file
void vsmc_rand_u01_oo(vsmc_rng rng, size_t n, double *r)
vsmc::u01_oo_distribution<double>
void vsmc_rand(vsmc_rng rng, size_t n, unsigned *r)
vsmc::uniform_bits_distribution
void vsmc_u01_rand_systematic(vsmc_rng rng, size_t n, double *r)
vsmc::u01_rand_systematic
void vsmc_rand_extreme_value(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::extreme_value_distribution<double>
void vsmc_rand_bernoulli(vsmc_rng rng, size_t n, int *r, double p)
std::bernoulli_distribution
void vsmc_rand_normal(vsmc_rng rng, size_t n, double *r, double mean, double stddev)
vsmc::normal_distribution<double>
void vsmc_rand_uniform_int_64(vsmc_rng rng, size_t n, long long *r, long long a, long long b)
std::uniform_int_distribution<long long>
void vsmc_rand_poisson(vsmc_rng rng, size_t n, int *r, double mean)
std::poisson_distribution<int>
vSMCRNGType
RNG types.
Definition: defines.h:75
void vsmc_rand_logistic(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::logistic_distribution<double>
void vsmc_rand_binomial(vsmc_rng rng, size_t n, int *r, int t, double p)
std::binomial_distribution<int>
void vsmc_rand_exponential(vsmc_rng rng, size_t n, double *r, double lambda)
vsmc::exponential_distribution<double>
void vsmc_rand_laplace(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::laplace_distribution<double>
void vsmc_seed_load(const void *mem)
vsmc::Seed::operator>>
void vsmc_rand_chi_squared(vsmc_rng rng, size_t n, double *r, double df)
vsmc::chi_squared_distribution<double>
void vsmc_rand_u01_oc(vsmc_rng rng, size_t n, double *r)
vsmc::u01_oc_distribution<double>
void vsmc_rand_lognormal(vsmc_rng rng, size_t n, double *r, double m, double s)
vsmc::lognormal_distribution<double>
int vsmc_rng_type_max()
The maximum of an integer that can be passed to where vSMCRNGType value is expected.
void vsmc_u01_rand_stratified(vsmc_rng rng, size_t n, double *r)
vsmc::u01_rand_stratifed
void vsmc_rand_cauchy(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::cauchy_distribution<double>
vSMC RNG types
Definition: defines.h:172
void vsmc_rand_arcsine(vsmc_rng rng, size_t n, double *r, double alpha, double beta)
vsmc::arcsine_distribution<double>
void vsmc_rng_load(vsmc_rng rng, void *mem)
RNGType::operator>>
void vsmc_rand_u01_co(vsmc_rng rng, size_t n, double *r)
vsmc::u01_co_distribution<double>
void vsmc_rand_fisher_f(vsmc_rng rng, size_t n, double *r, double df1, double df2)
vsmc::fisher_f_distribution<double>
void vsmc_rand_levy(vsmc_rng rng, size_t n, double *r, double a, double b)
vsmc::levy_distribution<double>