ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
randist.hpp
Go to the documentation of this file.
1/*
2 * $Id: randist.hpp 293 2012-12-17 20:27:36Z jdl3 $
3 * Copyright (C) 2010, 2020 John D Lamb
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef CCGSL_RANDIST_HPP
21#define CCGSL_RANDIST_HPP
22
23#include<new>
24#ifdef __GXX_EXPERIMENTAL_CXX0X__
25#include<stdexcept>
26#include<type_traits>
27#endif
28#include<gsl/gsl_randist.h>
29#include"rng.hpp"
30
31namespace gsl {
35 namespace ran {
39 class discrete_t {
40 public:
45 ccgsl_pointer = 0;
46 // just plausibly we could fail to allocate count
47 try { count = new size_t; } catch( std::bad_alloc& e ){
48 throw e;
49 }
50 *count = 1; // initially there is just one reference to ccgsl_pointer
51 }
52 // Refines random access container
53 // Refines assignable
54#ifndef DOXYGEN_SKIP
60 explicit discrete_t( size_t K, double const* P ){
61 ccgsl_pointer = gsl_ran_discrete_preproc( K, P );
62 // just plausibly we could allocate gsl_ran_discrete_t but not count
63 try { count = new size_t; } catch( std::bad_alloc& e ){
64 // try to tidy up before rethrowing
65 gsl_ran_discrete_free( ccgsl_pointer );
66 throw e;
67 }
68 *count = 1; // initially there is just one reference to ccgsl_pointer
69 }
70#endif // DOXYGEN_SKIP
75 template<typename ARRAY>
76 explicit discrete_t( ARRAY const& P ){
77 ccgsl_pointer = gsl_ran_discrete_preproc( P.size(), P.data() );
78 // just plausibly we could allocate gsl_ran_discrete_t but not count
79 try { count = new size_t; } catch( std::bad_alloc& e ){
80 // try to tidy up before rethrowing
81 gsl_ran_discrete_free( ccgsl_pointer );
82 throw e;
83 }
84 *count = 1; // initially there is just one reference to ccgsl_pointer
85 }
91 explicit discrete_t( gsl_ran_discrete_t* v ){
92 ccgsl_pointer = v;
93 // just plausibly we could fail to allocate count: no further action needed.
94 count = new size_t;
95 *count = 1; // initially there is just one reference to ccgsl_pointer
96 }
97 // copy constructor
103 count = v.count; if( count != 0 ) ++*count; }
104 // assignment operator
110 // first, possibly delete anything pointed to by this
111 if( --*count == 0 ){
112 if( ccgsl_pointer != 0 ) gsl_ran_discrete_free( ccgsl_pointer );
113 delete count;
114 } // Then copy
115 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
116 }
117 // destructor
122 if( --*count == 0 ){
123 // could have allocated null pointer
124 if( ccgsl_pointer != 0 ) gsl_ran_discrete_free( ccgsl_pointer );
125 delete count;
126 }
127 }
128 // Refines equality comparable
129 // == operator
136 bool operator==( discrete_t const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
137 // != operator
144 bool operator!=( discrete_t const& v ) const { return not operator==( v ); }
145 // Refines forward container
146 // Refines less than comparable
147 // operator<
156 bool operator<( discrete_t const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
157 // operator>
166 bool operator>( discrete_t const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
167 // operator<=
176 bool operator<=( discrete_t const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
177 // operator>=
186 bool operator>=( discrete_t const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
191 bool empty() const { return ccgsl_pointer == 0; }
192 // swap() --- should work even if sizes don't match
198 void swap( discrete_t& v ){
199 gsl_ran_discrete_t* tmp = ccgsl_pointer; ccgsl_pointer = v.ccgsl_pointer;
200 v.ccgsl_pointer = tmp; size_t* tmp2 = count; count = v.count; v.count = tmp2; }
201 private:
205 gsl_ran_discrete_t* ccgsl_pointer;
209 size_t* count;
210 public:
211 // shared reference functions
216 gsl_ran_discrete_t* get() const { return ccgsl_pointer; }
222 bool unique() const { return count != 0 and *count == 1; }
227 size_t use_count() const { return count == 0 ? 0 : *count; }
233#ifdef __GXX_EXPERIMENTAL_CXX0X__
234 explicit
235#endif
236 operator bool() const { return ccgsl_pointer != 0; }
237 };
238 // Functions
245 inline unsigned int bernoulli( rng const& r, double p ){
246 return gsl_ran_bernoulli( r.get(), p ); }
253 inline double bernoulli_pdf( unsigned int const k, double p ){
254 return gsl_ran_bernoulli_pdf( k, p ); }
262 inline double beta( rng const& r, double const a, double const b ){
263 return gsl_ran_beta( r.get(), a, b ); }
271 inline double beta_pdf( double const x, double const a, double const b ){
272 return gsl_ran_beta_pdf( x, a, b ); }
280 inline unsigned int binomial( rng const& r, double p, unsigned int n ){
281 return gsl_ran_binomial( r.get(), p, n ); }
289 inline unsigned int binomial_knuth( rng const& r, double p, unsigned int n ){
290 return gsl_ran_binomial_knuth( r.get(), p, n ); }
298 inline unsigned int binomial_tpe( rng const& r, double p, unsigned int n ){
299 return gsl_ran_binomial_tpe( r.get(), p, n ); }
307 inline double binomial_pdf( unsigned int const k, double const p, unsigned int const n ){
308 return gsl_ran_binomial_pdf( k, p, n ); }
315 inline double exponential( rng const& r, double const mu ){
316 return gsl_ran_exponential( r.get(), mu ); }
323 inline double exponential_pdf( double const x, double const mu ){
324 return gsl_ran_exponential_pdf( x, mu ); }
332 inline double exppow( rng const& r, double const a, double const b ){
333 return gsl_ran_exppow( r.get(), a, b ); }
341 inline double exppow_pdf( double const x, double const a, double const b ){
342 return gsl_ran_exppow_pdf( x, a, b ); }
349 inline double cauchy( rng const& r, double const a ){
350 return gsl_ran_cauchy( r.get(), a ); }
357 inline double cauchy_pdf( double const x, double const a ){
358 return gsl_ran_cauchy_pdf( x, a ); }
365 inline double chisq( rng const& r, double const nu ){
366 return gsl_ran_chisq( r.get(), nu ); }
373 inline double chisq_pdf( double const x, double const nu ){
374 return gsl_ran_chisq_pdf( x, nu ); }
382 inline void dirichlet( rng const& r, size_t const K, double const alpha[], double theta[] ){
383 gsl_ran_dirichlet( r.get(), K, alpha, theta ); }
391 inline double dirichlet_pdf( size_t const K, double const alpha[], double const theta[] ){
392 return gsl_ran_dirichlet_pdf( K, alpha, theta ); }
400 inline double dirichlet_lnpdf( size_t const K, double const alpha[], double const theta[] ){
401 return gsl_ran_dirichlet_lnpdf( K, alpha, theta ); }
409 inline double erlang( rng const& r, double const a, double const n ){
410 return gsl_ran_erlang( r.get(), a, n ); }
418 inline double erlang_pdf( double const x, double const a, double const n ){
419 return gsl_ran_erlang_pdf( x, a, n ); }
427 inline double fdist( rng const& r, double const nu1, double const nu2 ){
428 return gsl_ran_fdist( r.get(), nu1, nu2 ); }
436 inline double fdist_pdf( double const x, double const nu1, double const nu2 ){
437 return gsl_ran_fdist_pdf( x, nu1, nu2 ); }
445 inline double flat( rng const& r, double const a, double const b ){
446 return gsl_ran_flat( r.get(), a, b ); }
454 inline double flat_pdf( double x, double const a, double const b ){
455 return gsl_ran_flat_pdf( x, a, b ); }
463 inline double gamma( rng const& r, double const a, double const b ){
464 return gsl_ran_gamma( r.get(), a, b ); }
471 inline double gamma_int( rng const& r, unsigned int const a ){
472 return gsl_ran_gamma_int( r.get(), a ); }
480 inline double gamma_pdf( double const x, double const a, double const b ){
481 return gsl_ran_gamma_pdf( x, a, b ); }
489 inline double gamma_mt( rng const& r, double const a, double const b ){
490 return gsl_ran_gamma_mt( r.get(), a, b ); }
498 inline double gamma_knuth( rng const& r, double const a, double const b ){
499 return gsl_ran_gamma_knuth( r.get(), a, b ); }
506 inline double gaussian( rng const& r, double const sigma ){
507 return gsl_ran_gaussian( r.get(), sigma ); }
514 inline double gaussian_ratio_method( rng const& r, double const sigma ){
515 return gsl_ran_gaussian_ratio_method( r.get(), sigma ); }
522 inline double gaussian_ziggurat( rng const& r, double const sigma ){
523 return gsl_ran_gaussian_ziggurat( r.get(), sigma ); }
530 inline double gaussian_pdf( double const x, double const sigma ){
531 return gsl_ran_gaussian_pdf( x, sigma ); }
537 inline double ugaussian( rng const& r ){
538 return gsl_ran_ugaussian( r.get() ); }
544 inline double ugaussian_ratio_method( rng const& r ){
545 return gsl_ran_ugaussian_ratio_method( r.get() ); }
551 inline double ugaussian_pdf( double const x ){
552 return gsl_ran_ugaussian_pdf( x ); }
560 inline double gaussian_tail( rng const& r, double const a, double const sigma ){
561 return gsl_ran_gaussian_tail( r.get(), a, sigma ); }
569 inline double gaussian_tail_pdf( double const x, double const a, double const sigma ){
570 return gsl_ran_gaussian_tail_pdf( x, a, sigma ); }
577 inline double ugaussian_tail( rng const& r, double const a ){
578 return gsl_ran_ugaussian_tail( r.get(), a ); }
585 inline double ugaussian_tail_pdf( double const x, double const a ){
586 return gsl_ran_ugaussian_tail_pdf( x, a ); }
587#ifndef DOXYGEN_SKIP
597 inline void bivariate_gaussian( rng const& r, double sigma_x, double sigma_y,
598 double rho, double* x, double* y ){
599 gsl_ran_bivariate_gaussian( r.get(), sigma_x, sigma_y, rho, x, y ); }
600#endif // DOXYGEN_SKIP
610 inline void bivariate_gaussian( rng const& r, double sigma_x, double sigma_y,
611 double rho, double& x, double& y ){
612 gsl_ran_bivariate_gaussian( r.get(), sigma_x, sigma_y, rho, &x, &y ); }
622 inline double bivariate_gaussian_pdf( double const x, double const y, double const sigma_x,
623 double const sigma_y, double const rho ){
624 return gsl_ran_bivariate_gaussian_pdf( x, y, sigma_x, sigma_y, rho ); }
630 inline double landau( rng const& r ){
631 return gsl_ran_landau( r.get() ); }
637 inline double landau_pdf( double const x ){ return gsl_ran_landau_pdf( x ); }
644 inline unsigned int geometric( rng const& r, double const p ){
645 return gsl_ran_geometric( r.get(), p ); }
652 inline double geometric_pdf( unsigned int const k, double const p ){
653 return gsl_ran_geometric_pdf( k, p ); }
662 inline unsigned int hypergeometric( rng const& r, unsigned int n1, unsigned int n2, unsigned int t ){
663 return gsl_ran_hypergeometric( r.get(), n1, n2, t ); }
672 inline double hypergeometric_pdf( unsigned int const k, unsigned int const n1,
673 unsigned int const n2, unsigned int t ){
674 return gsl_ran_hypergeometric_pdf( k, n1, n2, t ); }
682 inline double gumbel1( rng const& r, double const a, double const b ){
683 return gsl_ran_gumbel1( r.get(), a, b ); }
691 inline double gumbel1_pdf( double const x, double const a, double const b ){
692 return gsl_ran_gumbel1_pdf( x, a, b ); }
700 inline double gumbel2( rng const& r, double const a, double const b ){
701 return gsl_ran_gumbel2( r.get(), a, b ); }
709 inline double gumbel2_pdf( double const x, double const a, double const b ){
710 return gsl_ran_gumbel2_pdf( x, a, b ); }
717 inline double logistic( rng const& r, double const a ){
718 return gsl_ran_logistic( r.get(), a ); }
725 inline double logistic_pdf( double const x, double const a ){
726 return gsl_ran_logistic_pdf( x, a ); }
734 inline double lognormal( rng const& r, double const zeta, double const sigma ){
735 return gsl_ran_lognormal( r.get(), zeta, sigma ); }
743 inline double lognormal_pdf( double const x, double const zeta, double const sigma ){
744 return gsl_ran_lognormal_pdf( x, zeta, sigma ); }
751 inline unsigned int logarithmic( rng const& r, double const p ){
752 return gsl_ran_logarithmic( r.get(), p ); }
759 inline double logarithmic_pdf( unsigned int const k, double const p ){
760 return gsl_ran_logarithmic_pdf( k, p ); }
769 inline void multinomial( rng const& r, size_t const K, unsigned int const N,
770 double const p[], unsigned int n[] ){
771 gsl_ran_multinomial( r.get(), K, N, p, n ); }
779 inline double multinomial_pdf( size_t const K, double const p[], unsigned int const n[] ){
780 return gsl_ran_multinomial_pdf( K, p, n ); }
788 inline double multinomial_lnpdf( size_t const K, double const p[], unsigned int const n[] ){
789 return gsl_ran_multinomial_lnpdf( K, p, n ); }
797 inline unsigned int negative_binomial( rng const& r, double p, double n ){
798 return gsl_ran_negative_binomial( r.get(), p, n ); }
806 inline double negative_binomial_pdf( unsigned int const k, double const p, double n ){
807 return gsl_ran_negative_binomial_pdf( k, p, n ); }
815 inline unsigned int pascal( rng const& r, double p, unsigned int n ){
816 return gsl_ran_pascal( r.get(), p, n ); }
824 inline double pascal_pdf( unsigned int const k, double const p, unsigned int n ){
825 return gsl_ran_pascal_pdf( k, p, n ); }
833 inline double pareto( rng const& r, double a, double const b ){
834 return gsl_ran_pareto( r.get(), a, b ); }
842 inline double pareto_pdf( double const x, double const a, double const b ){
843 return gsl_ran_pareto_pdf( x, a, b ); }
850 inline unsigned int poisson( rng const& r, double mu ){
851 return gsl_ran_poisson( r.get(), mu ); }
859 inline void poisson_array( rng const& r, size_t n, unsigned int array[], double mu ){
860 gsl_ran_poisson_array( r.get(), n, array, mu ); }
867 inline double poisson_pdf( unsigned int const k, double const mu ){
868 return gsl_ran_poisson_pdf( k, mu ); }
875 inline double rayleigh( rng const& r, double const sigma ){
876 return gsl_ran_rayleigh( r.get(), sigma ); }
883 inline double rayleigh_pdf( double const x, double const sigma ){
884 return gsl_ran_rayleigh_pdf( x, sigma ); }
892 inline double rayleigh_tail( rng const& r, double const a, double const sigma ){
893 return gsl_ran_rayleigh_tail( r.get(), a, sigma ); }
901 inline double rayleigh_tail_pdf( double const x, double const a, double const sigma ){
902 return gsl_ran_rayleigh_tail_pdf( x, a, sigma ); }
909 inline double tdist( rng const& r, double const nu ){
910 return gsl_ran_tdist( r.get(), nu ); }
917 inline double tdist_pdf( double const x, double const nu ){
918 return gsl_ran_tdist_pdf( x, nu ); }
925 inline double laplace( rng const& r, double const a ){
926 return gsl_ran_laplace( r.get(), a ); }
933 inline double laplace_pdf( double const x, double const a ){
934 return gsl_ran_laplace_pdf( x, a ); }
942 inline double levy( rng const& r, double const c, double const alpha ){
943 return gsl_ran_levy( r.get(), c, alpha ); }
952 inline double levy_skew( rng const& r, double const c, double const alpha, double const beta ){
953 return gsl_ran_levy_skew( r.get(), c, alpha, beta ); }
961 inline double weibull( rng const& r, double const a, double const b ){
962 return gsl_ran_weibull( r.get(), a, b ); }
970 inline double weibull_pdf( double const x, double const a, double const b ){
971 return gsl_ran_weibull_pdf( x, a, b ); }
972#ifndef DOXYGEN_SKIP
979 inline void dir_2d( rng const& r, double* x, double* y ){
980 gsl_ran_dir_2d( r.get(), x, y ); }
981#endif // DOXYGEN_SKIP
988 inline void dir_2d( rng const& r, double& x, double& y ){
989 gsl_ran_dir_2d( r.get(), &x, &y ); }
990#ifndef DOXYGEN_SKIP
997 inline void dir_2d_trig_method( rng const& r, double* x, double* y ){
998 gsl_ran_dir_2d_trig_method( r.get(), x, y ); }
999#endif // DOXYGEN_SKIP
1006 inline void dir_2d_trig_method( rng const& r, double& x, double& y ){
1007 gsl_ran_dir_2d_trig_method( r.get(), &x, &y ); }
1008#ifndef DOXYGEN_SKIP
1016 inline void dir_3d( rng const& r, double* x, double* y, double* z ){
1017 gsl_ran_dir_3d( r.get(), x, y, z ); }
1018#endif // DOXYGEN_SKIP
1026 inline void dir_3d( rng const& r, double& x, double& y, double& z ){
1027 gsl_ran_dir_3d( r.get(), &x, &y, &z ); }
1028#ifndef DOXYGEN_SKIP
1035 inline void dir_nd( rng const& r, size_t n, double* x ){
1036 gsl_ran_dir_nd( r.get(), n, x ); }
1037#endif // DOXYGEN_SKIP
1043 template<typename DATA>
1044 inline void dir_nd( rng const& r, DATA& x ){
1045 gsl_ran_dir_nd( r.get(), x.size(), x.data() ); }
1046#ifndef DOXYGEN_SKIP
1054 inline void shuffle( rng const& r, void* base, size_t nmembm, size_t size ){
1055 gsl_ran_shuffle( r.get(), base, nmembm, size ); }
1056#endif // DOXYGEN_SKIP
1062 template<typename ARRAY>
1063 inline void shuffle( rng const& r, ARRAY& base ){
1064 gsl_ran_shuffle( r.get(), base.data(), base.size(),
1065 sizeof( typename ARRAY::value_type ) ); }
1066#ifndef DOXYGEN_SKIP
1077 inline int choose( rng const& r, void* dest, size_t k, void* src, size_t n, size_t size ){
1078 return gsl_ran_choose( r.get(), dest, k, src, n, size ); }
1079#endif // DOXYGEN_SKIP
1087 template<typename ARRAY1, typename ARRAY2>
1088 inline int choose( rng const& r, ARRAY1& dest, ARRAY2& src ){
1089#ifdef __GXX_EXPERIMENTAL_CXX0X__
1090 if( not std::is_same<typename ARRAY1::value_type,typename ARRAY2::value_type>::value )
1091 return GSL_EFAILED;
1092#endif
1093 return gsl_ran_choose( r.get(), dest.data(), dest.size(), src.data(), src.size(),
1094 sizeof( typename ARRAY1::value_type ) ); }
1095#ifndef DOXYGEN_SKIP
1105 inline void sample( rng const& r, void* dest, size_t k, void* src, size_t n, size_t size ){
1106 gsl_ran_sample( r.get(), dest, k, src, n, size ); }
1107#endif // DOXYGEN_SKIP
1114 template<typename ARRAY1, typename ARRAY2>
1115 inline void sample( rng const& r, ARRAY1& dest, ARRAY2& src ){
1116#ifdef __GXX_EXPERIMENTAL_CXX0X__
1117 if( not std::is_same<typename ARRAY1::value_type,typename ARRAY2::value_type>::value )
1118 throw std::invalid_argument( "ran::sample: arrays hold different types of data." );
1119#endif
1120 gsl_ran_sample( r.get(), dest.data(), dest.size(), src.data(), src.size(),
1121 sizeof( typename ARRAY1::value_type ) ); }
1128 inline size_t discrete( rng const& r, discrete_t const& g ){
1129 return gsl_ran_discrete( r.get(), g.get() ); }
1136 inline double discrete_pdf( size_t k, discrete_t const& g ){
1137 return gsl_ran_discrete_pdf( k, g.get() ); }
1138 }
1139}
1140
1141#endif
Class for walker algorithm.
Definition: randist.hpp:39
discrete_t(gsl_ran_discrete_t *v)
Could construct from a gsl_ran_discrete_t.
Definition: randist.hpp:91
bool operator<(discrete_t const &v) const
A container needs to define an ordering for sorting.
Definition: randist.hpp:156
bool operator==(discrete_t const &v) const
Two discrete_t are identically equal if their elements are identical.
Definition: randist.hpp:136
gsl_ran_discrete_t * get() const
Get the gsl_ran_discrete_t.
Definition: randist.hpp:216
discrete_t & operator=(discrete_t const &v)
The assignment operator.
Definition: randist.hpp:109
discrete_t(discrete_t const &v)
The copy constructor.
Definition: randist.hpp:102
void swap(discrete_t &v)
Swap two discrete_t.
Definition: randist.hpp:198
bool operator!=(discrete_t const &v) const
Two discrete_t are different equal if their elements are not identical.
Definition: randist.hpp:144
bool operator<=(discrete_t const &v) const
A container needs to define an ordering for sorting.
Definition: randist.hpp:176
gsl_ran_discrete_t * ccgsl_pointer
The shared pointer.
Definition: randist.hpp:205
bool unique() const
Find if this is the only object sharing the gsl_ran_discrete_t.
Definition: randist.hpp:222
~discrete_t()
The destructor only deletes the pointers if count reaches zero.
Definition: randist.hpp:121
bool operator>=(discrete_t const &v) const
A container needs to define an ordering for sorting.
Definition: randist.hpp:186
size_t use_count() const
Find how many discrete_t objects share this pointer.
Definition: randist.hpp:227
discrete_t()
The default constructor is only really useful for assigning to.
Definition: randist.hpp:44
bool empty() const
Find if the discrete_t is empty.
Definition: randist.hpp:191
size_t * count
The shared reference count.
Definition: randist.hpp:209
bool operator>(discrete_t const &v) const
A container needs to define an ordering for sorting.
Definition: randist.hpp:166
discrete_t(ARRAY const &P)
The standard constructor creates a new discrete_t.
Definition: randist.hpp:76
Random number generator.
Definition: rng.hpp:31
gsl_rng * get() const
Get the gsl_rng.
Definition: rng.hpp:525
size_t size(series const &cs)
C++ version of gsl_cheb_size().
Definition: chebyshev.hpp:287
void dir_2d_trig_method(rng const &r, double &x, double &y)
C++ version of gsl_ran_dir_2d_trig_method().
Definition: randist.hpp:1006
double geometric_pdf(unsigned int const k, double const p)
C++ version of gsl_ran_geometric_pdf().
Definition: randist.hpp:652
double dirichlet_lnpdf(size_t const K, double const alpha[], double const theta[])
C++ version of gsl_ran_dirichlet_lnpdf().
Definition: randist.hpp:400
double gumbel2_pdf(double const x, double const a, double const b)
C++ version of gsl_ran_gumbel2_pdf().
Definition: randist.hpp:709
double gamma_knuth(rng const &r, double const a, double const b)
C++ version of gsl_ran_gamma_knuth().
Definition: randist.hpp:498
int choose(rng const &r, ARRAY1 &dest, ARRAY2 &src)
C++ version of gsl_ran_choose().
Definition: randist.hpp:1088
double landau(rng const &r)
C++ version of gsl_ran_landau().
Definition: randist.hpp:630
unsigned int bernoulli(rng const &r, double p)
C++ version of gsl_ran_bernoulli().
Definition: randist.hpp:245
double exppow(rng const &r, double const a, double const b)
C++ version of gsl_ran_exppow().
Definition: randist.hpp:332
double gaussian_pdf(double const x, double const sigma)
C++ version of gsl_ran_gaussian_pdf().
Definition: randist.hpp:530
double fdist_pdf(double const x, double const nu1, double const nu2)
C++ version of gsl_ran_fdist_pdf().
Definition: randist.hpp:436
double gaussian(rng const &r, double const sigma)
C++ version of gsl_ran_gaussian().
Definition: randist.hpp:506
double negative_binomial_pdf(unsigned int const k, double const p, double n)
C++ version of gsl_ran_negative_binomial_pdf().
Definition: randist.hpp:806
double pareto_pdf(double const x, double const a, double const b)
C++ version of gsl_ran_pareto_pdf().
Definition: randist.hpp:842
double exppow_pdf(double const x, double const a, double const b)
C++ version of gsl_ran_exppow_pdf().
Definition: randist.hpp:341
double levy(rng const &r, double const c, double const alpha)
C++ version of gsl_ran_levy().
Definition: randist.hpp:942
double binomial_pdf(unsigned int const k, double const p, unsigned int const n)
C++ version of gsl_ran_binomial_pdf().
Definition: randist.hpp:307
unsigned int hypergeometric(rng const &r, unsigned int n1, unsigned int n2, unsigned int t)
C++ version of gsl_ran_hypergeometric().
Definition: randist.hpp:662
double cauchy(rng const &r, double const a)
C++ version of gsl_ran_cauchy().
Definition: randist.hpp:349
double tdist_pdf(double const x, double const nu)
C++ version of gsl_ran_tdist_pdf().
Definition: randist.hpp:917
double flat(rng const &r, double const a, double const b)
C++ version of gsl_ran_flat().
Definition: randist.hpp:445
double erlang_pdf(double const x, double const a, double const n)
C++ version of gsl_ran_erlang_pdf().
Definition: randist.hpp:418
double pascal_pdf(unsigned int const k, double const p, unsigned int n)
C++ version of gsl_ran_pascal_pdf().
Definition: randist.hpp:824
double weibull(rng const &r, double const a, double const b)
C++ version of gsl_ran_weibull().
Definition: randist.hpp:961
double cauchy_pdf(double const x, double const a)
C++ version of gsl_ran_cauchy_pdf().
Definition: randist.hpp:357
void dir_nd(rng const &r, DATA &x)
C++ version of gsl_ran_dir_nd().
Definition: randist.hpp:1044
double gumbel1(rng const &r, double const a, double const b)
C++ version of gsl_ran_gumbel1().
Definition: randist.hpp:682
double beta(rng const &r, double const a, double const b)
C++ version of gsl_ran_beta().
Definition: randist.hpp:262
size_t discrete(rng const &r, discrete_t const &g)
C++ version of gsl_ran_discrete().
Definition: randist.hpp:1128
double multinomial_lnpdf(size_t const K, double const p[], unsigned int const n[])
C++ version of gsl_ran_multinomial_lnpdf().
Definition: randist.hpp:788
unsigned int binomial_tpe(rng const &r, double p, unsigned int n)
C++ version of gsl_ran_binomial_tpe().
Definition: randist.hpp:298
double dirichlet_pdf(size_t const K, double const alpha[], double const theta[])
C++ version of gsl_ran_dirichlet_pdf().
Definition: randist.hpp:391
double rayleigh_pdf(double const x, double const sigma)
C++ version of gsl_ran_rayleigh_pdf().
Definition: randist.hpp:883
void sample(rng const &r, ARRAY1 &dest, ARRAY2 &src)
C++ version of gsl_ran_sample().
Definition: randist.hpp:1115
double chisq_pdf(double const x, double const nu)
C++ version of gsl_ran_chisq_pdf().
Definition: randist.hpp:373
double rayleigh_tail_pdf(double const x, double const a, double const sigma)
C++ version of gsl_ran_rayleigh_tail_pdf().
Definition: randist.hpp:901
double levy_skew(rng const &r, double const c, double const alpha, double const beta)
C++ version of gsl_ran_levy_skew().
Definition: randist.hpp:952
double gaussian_tail(rng const &r, double const a, double const sigma)
C++ version of gsl_ran_gaussian_tail().
Definition: randist.hpp:560
double poisson_pdf(unsigned int const k, double const mu)
C++ version of gsl_ran_poisson_pdf().
Definition: randist.hpp:867
double rayleigh(rng const &r, double const sigma)
C++ version of gsl_ran_rayleigh().
Definition: randist.hpp:875
double erlang(rng const &r, double const a, double const n)
C++ version of gsl_ran_erlang().
Definition: randist.hpp:409
double gaussian_ratio_method(rng const &r, double const sigma)
C++ version of gsl_ran_gaussian_ratio_method().
Definition: randist.hpp:514
double beta_pdf(double const x, double const a, double const b)
C++ version of gsl_ran_beta_pdf().
Definition: randist.hpp:271
double landau_pdf(double const x)
C++ version of gsl_ran_landau_pdf().
Definition: randist.hpp:637
void poisson_array(rng const &r, size_t n, unsigned int array[], double mu)
C++ version of gsl_ran_poisson_array().
Definition: randist.hpp:859
double lognormal(rng const &r, double const zeta, double const sigma)
C++ version of gsl_ran_lognormal().
Definition: randist.hpp:734
double hypergeometric_pdf(unsigned int const k, unsigned int const n1, unsigned int const n2, unsigned int t)
C++ version of gsl_ran_hypergeometric_pdf().
Definition: randist.hpp:672
double gaussian_ziggurat(rng const &r, double const sigma)
C++ version of gsl_ran_gaussian_ziggurat().
Definition: randist.hpp:522
double gamma_int(rng const &r, unsigned int const a)
C++ version of gsl_ran_gamma_int().
Definition: randist.hpp:471
double ugaussian_tail(rng const &r, double const a)
C++ version of gsl_ran_ugaussian_tail().
Definition: randist.hpp:577
double weibull_pdf(double const x, double const a, double const b)
C++ version of gsl_ran_weibull_pdf().
Definition: randist.hpp:970
double laplace(rng const &r, double const a)
C++ version of gsl_ran_laplace().
Definition: randist.hpp:925
unsigned int geometric(rng const &r, double const p)
C++ version of gsl_ran_geometric().
Definition: randist.hpp:644
void multinomial(rng const &r, size_t const K, unsigned int const N, double const p[], unsigned int n[])
C++ version of gsl_ran_multinomial().
Definition: randist.hpp:769
double logistic(rng const &r, double const a)
C++ version of gsl_ran_logistic().
Definition: randist.hpp:717
double gamma(rng const &r, double const a, double const b)
C++ version of gsl_ran_gamma().
Definition: randist.hpp:463
unsigned int binomial(rng const &r, double p, unsigned int n)
C++ version of gsl_ran_binomial().
Definition: randist.hpp:280
double exponential(rng const &r, double const mu)
C++ version of gsl_ran_exponential().
Definition: randist.hpp:315
double rayleigh_tail(rng const &r, double const a, double const sigma)
C++ version of gsl_ran_rayleigh_tail().
Definition: randist.hpp:892
void dirichlet(rng const &r, size_t const K, double const alpha[], double theta[])
C++ version of gsl_ran_dirichlet().
Definition: randist.hpp:382
double ugaussian_tail_pdf(double const x, double const a)
C++ version of gsl_ran_ugaussian_tail_pdf().
Definition: randist.hpp:585
unsigned int logarithmic(rng const &r, double const p)
C++ version of gsl_ran_logarithmic().
Definition: randist.hpp:751
unsigned int poisson(rng const &r, double mu)
C++ version of gsl_ran_poisson().
Definition: randist.hpp:850
unsigned int negative_binomial(rng const &r, double p, double n)
C++ version of gsl_ran_negative_binomial().
Definition: randist.hpp:797
double gaussian_tail_pdf(double const x, double const a, double const sigma)
C++ version of gsl_ran_gaussian_tail_pdf().
Definition: randist.hpp:569
void dir_2d(rng const &r, double &x, double &y)
C++ version of gsl_ran_dir_2d().
Definition: randist.hpp:988
double lognormal_pdf(double const x, double const zeta, double const sigma)
C++ version of gsl_ran_lognormal_pdf().
Definition: randist.hpp:743
double exponential_pdf(double const x, double const mu)
C++ version of gsl_ran_exponential_pdf().
Definition: randist.hpp:323
void dir_3d(rng const &r, double &x, double &y, double &z)
C++ version of gsl_ran_dir_3d().
Definition: randist.hpp:1026
double bivariate_gaussian_pdf(double const x, double const y, double const sigma_x, double const sigma_y, double const rho)
C++ version of gsl_ran_bivariate_gaussian_pdf().
Definition: randist.hpp:622
double tdist(rng const &r, double const nu)
C++ version of gsl_ran_tdist().
Definition: randist.hpp:909
double gamma_pdf(double const x, double const a, double const b)
C++ version of gsl_ran_gamma_pdf().
Definition: randist.hpp:480
unsigned int pascal(rng const &r, double p, unsigned int n)
C++ version of gsl_ran_pascal().
Definition: randist.hpp:815
double logarithmic_pdf(unsigned int const k, double const p)
C++ version of gsl_ran_logarithmic_pdf().
Definition: randist.hpp:759
double bernoulli_pdf(unsigned int const k, double p)
C++ version of gsl_ran_bernoulli_pdf().
Definition: randist.hpp:253
double chisq(rng const &r, double const nu)
C++ version of gsl_ran_chisq().
Definition: randist.hpp:365
double ugaussian_ratio_method(rng const &r)
C++ version of gsl_ran_ugaussian_ratio_method().
Definition: randist.hpp:544
void shuffle(rng const &r, ARRAY &base)
C++ version of gsl_ran_shuffle().
Definition: randist.hpp:1063
double pareto(rng const &r, double a, double const b)
C++ version of gsl_ran_pareto().
Definition: randist.hpp:833
double flat_pdf(double x, double const a, double const b)
C++ version of gsl_ran_flat_pdf().
Definition: randist.hpp:454
void bivariate_gaussian(rng const &r, double sigma_x, double sigma_y, double rho, double &x, double &y)
C++ version of gsl_ran_bivariate_gaussian().
Definition: randist.hpp:610
double logistic_pdf(double const x, double const a)
C++ version of gsl_ran_logistic_pdf().
Definition: randist.hpp:725
unsigned int binomial_knuth(rng const &r, double p, unsigned int n)
C++ version of gsl_ran_binomial_knuth().
Definition: randist.hpp:289
double ugaussian(rng const &r)
C++ version of gsl_ran_ugaussian().
Definition: randist.hpp:537
double gamma_mt(rng const &r, double const a, double const b)
C++ version of gsl_ran_gamma_mt().
Definition: randist.hpp:489
double discrete_pdf(size_t k, discrete_t const &g)
C++ version of gsl_ran_discrete_pdf().
Definition: randist.hpp:1136
double gumbel1_pdf(double const x, double const a, double const b)
C++ version of gsl_ran_gumbel1_pdf().
Definition: randist.hpp:691
double ugaussian_pdf(double const x)
C++ version of gsl_ran_ugaussian_pdf().
Definition: randist.hpp:551
double fdist(rng const &r, double const nu1, double const nu2)
C++ version of gsl_ran_fdist().
Definition: randist.hpp:427
double multinomial_pdf(size_t const K, double const p[], unsigned int const n[])
C++ version of gsl_ran_multinomial_pdf().
Definition: randist.hpp:779
double gumbel2(rng const &r, double const a, double const b)
C++ version of gsl_ran_gumbel2().
Definition: randist.hpp:700
double laplace_pdf(double const x, double const a)
C++ version of gsl_ran_laplace_pdf().
Definition: randist.hpp:933
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
Definition: rstat.hpp:299
double P(double phi, double k, double n, mode_t mode)
C++ version of gsl_sf_ellint_P().
Definition: sf_ellint.hpp:182
int array(int const nmax, double const x, DATA &result_array)
C++ version of gsl_sf_hermite_array().
Definition: sf_hermite.hpp:324
double b(int order, double qq)
C++ version of gsl_sf_mathieu_b().
Definition: sf_mathieu.hpp:298
double a(int order, double qq)
C++ version of gsl_sf_mathieu_a().
Definition: sf_mathieu.hpp:272
double zeta(double const s)
C++ version of gsl_sf_zeta().
Definition: sf_zeta.hpp:72
The gsl package creates an interface to the GNU Scientific Library for C++.
Definition: blas.hpp:34