Go to the documentation of this file.
26 #ifndef O2SCL_PROB_DENS_FUNC_H
27 #define O2SCL_PROB_DENS_FUNC_H
29 #include <gsl/gsl_rng.h>
30 #include <gsl/gsl_randist.h>
31 #include <gsl/gsl_cdf.h>
34 #include <gsl/gsl_poly.h>
38 #include <boost/numeric/ublas/vector.hpp>
39 #include <boost/numeric/ublas/operation.hpp>
41 #include <o2scl/hist.h>
42 #include <o2scl/rng_gsl.h>
43 #include <o2scl/search_vec.h>
44 #include <o2scl/cholesky.h>
46 #include <o2scl/vec_stats.h>
48 #ifndef DOXYGEN_NO_O2NS
76 virtual double pdf(
double x)
const {
88 virtual double cdf(
double x)
const {
149 O2SCL_ERR2(
"Tried to create a Gaussian dist. with sigma",
150 "<0 in prob_dens_gaussian::prob_dens_gaussian().",
194 "in prob_dens_gaussian::prob_dens_gaussian().",
209 O2SCL_ERR2(
"Width not set in prob_dens_gaussian::",
218 O2SCL_ERR2(
"Width not set in prob_dens_gaussian::",
225 virtual double pdf(
double x)
const {
227 O2SCL_ERR2(
"Width not set in prob_dens_gaussian::",
236 O2SCL_ERR2(
"Width not set in prob_dens_gaussian::",
243 virtual double cdf(
double x)
const {
245 O2SCL_ERR2(
"Width not set in prob_dens_gaussian::",
254 O2SCL_ERR2(
"Width not set in prob_dens_gaussian::",
257 if (in_cdf<0.0 || in_cdf>1.0) {
258 O2SCL_ERR2(
"Requested cdf inverse outside of [0,1] in ",
259 "prob_dens_gaussian::invert_cdf().",
exc_einval);
267 O2SCL_ERR2(
"Width not set in prob_dens_gaussian::",
348 if (
this==&pdg)
return *
this;
377 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
386 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
395 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
398 return gsl_ran_flat(&
r,
ll,
ul);
402 virtual double pdf(
double x)
const {
404 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
407 if (x<ll || x>
ul)
return 0.0;
408 return gsl_ran_flat_pdf(x,
ll,
ul);
414 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
417 if (x<ll || x>
ul)
return 0.0;
418 return log(gsl_ran_flat_pdf(x,
ll,
ul));
422 virtual double cdf(
double x)
const {
424 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
427 if (x<
ll)
return 0.0;
428 if (x>
ul)
return 1.0;
429 return gsl_cdf_flat_P(x,
ll,
ul);
435 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
438 if (in_cdf<0.0 || in_cdf>1.0) {
439 O2SCL_ERR2(
"Requested cdf inverse outside of [0,1] in ",
440 "prob_dens_uniform::invert_cdf().",
exc_einval);
442 return gsl_cdf_flat_Pinv(in_cdf,
ll,
ul);
448 O2SCL_ERR2(
"Limits not set in prob_dens_uniform::",
510 O2SCL_ERR2(
"Tried to create log normal dist. with mu or sigma",
511 "<0 in prob_dens_lognormal::prob_dens_lognormal().",
530 if (
this==&pdg)
return *
this;
540 O2SCL_ERR2(
"Tried to set mu or sigma negative",
541 "in prob_dens_lognormal::prob_dens_lognormal().",
559 virtual double pdf(
double x)
const {
563 return gsl_ran_lognormal_pdf(x,
mu_,
sigma_);
571 return log(gsl_ran_lognormal_pdf(x,
mu_,
sigma_));
575 virtual double cdf(
double x)
const {
579 return gsl_cdf_lognormal_P(x,
mu_,
sigma_);
584 if (in_cdf<0.0 || in_cdf>1.0) {
585 O2SCL_ERR2(
"Requested cdf inverse outside of [0,1] in ",
586 "prob_dens_lognormal::invert_cdf().",
exc_einval);
588 return gsl_cdf_lognormal_Pinv(in_cdf,
mu_,
sigma_);
594 O2SCL_ERR2(
"Parameters not set in prob_dens_lognormal::",
660 virtual double pdf(
double x)
const;
663 virtual double log_pdf(
double x)
const;
666 virtual double cdf(
double x)
const;
683 template<
class vec_t=boost::numeric::ublas::vector<
double> >
689 virtual size_t dim()
const {
695 virtual double pdf(
const vec_t &x)
const {
701 virtual double log_pdf(
const vec_t &x)
const {
703 if (!std::isfinite(val) || val<0.0) {
707 double val2=log(
pdf(x));
708 if (!std::isfinite(val2)) {
709 std::cout << val <<
" " << val2 << std::endl;
727 template<
class vec_t=boost::numeric::ublas::vector<
double> >
733 std::vector<prob_dens_func>
list;
757 virtual size_t dim()
const {
762 virtual double pdf(
const vec_t &x)
const {
764 for(
size_t i=0;i<
list.size();i++) ret*=
list[i].
pdf(x[i]);
769 virtual double log_pdf(
const vec_t &x)
const {
771 for(
size_t i=0;i<
list.size();i++) ret*=
list[i].
pdf(x[i]);
777 for(
size_t i=0;i<
list.size();i++) x[i]=
list[i]();
835 template<
class vec_t=boost::numeric::ublas::vector<
double> >
888 void set(
double x_cent,
double y_cent,
double x_std,
double y_std,
890 if (fabs(covar)>=1.0) {
891 O2SCL_ERR2(
"Covariance cannot have magnitude equal or larger than ",
892 "1 in prob_dens_mdim_biv_gaussian::set().",
905 virtual double pdf(
const vec_t &v)
const {
906 double x=v[0], y=v[1];
922 double arg=-2.0*log(1.0-integral);
932 virtual void contour(
double level,
double theta, vec_t &x) {
934 O2SCL_ERR2(
"Cannot produce contours for negative values in ",
935 "prob_dens_mdim_biv_gaussian::contour().",
940 O2SCL_ERR2(
"Cannot produce contours larger than maximum in ",
941 "prob_dens_mdim_biv_gaussian::contour().",
946 double r2=arg/(cos(theta)*cos(theta)/
sig_x/
sig_x+
949 x[0]=sqrt(r2)*cos(theta)+
x0;
950 x[1]=sqrt(r2)*sin(theta)+
y0;
985 template<
class vec_t=boost::numeric::ublas::vector<
double>,
986 class mat_t=boost::numeric::ublas::matrix<
double> >
1069 if (
this!=&pdmg_loc) {
1087 template<
class mat2_t,
class vec2_t,
1089 int set(
size_t p_mdim,
size_t n_pts,
const mat2_t &pts,
1090 const vec2_t &vals, vec_t &peak_arg, mat_t &covar_arg) {
1094 for(
size_t i=0;i<p_mdim;i++) {
1095 const mat2_col_t col(pts,i);
1096 peak_arg[i]=o2scl::wvector_mean<mat2_col_t>(n_pts,col,vals);
1098 covar_arg(i,i)=o2scl::wvector_stddev<mat2_col_t>(n_pts,col,vals);
1099 covar_arg(i,i)*=covar_arg(i,i);
1102 for(
size_t i=0;i<p_mdim;i++) {
1103 mat2_col_t col_i(pts,i);
1104 for(
size_t j=i+1;j<p_mdim;j++) {
1105 const mat2_col_t col_j(pts,j);
1111 set(p_mdim,peak_arg,covar_arg);
1121 template<
class mat2_t,
class vec2_t,
1123 int set(
size_t p_mdim,
size_t n_pts,
const mat2_t &pts,
1124 const vec2_t &vals) {
1126 vec_t peak_arg(p_mdim);
1127 mat_t covar_arg(p_mdim,p_mdim);
1129 set<mat2_t,vec2_t,mat2_col_t>(p_mdim,n_pts,pts,vals,peak_arg,covar_arg);
1136 set(p_ndim,p_peak,covar);
1144 void set(
size_t p_ndim, vec_t &p_peak, mat_t &covar) {
1146 O2SCL_ERR(
"Zero dimension in prob_dens_mdim_gaussian::set().",
1152 for(
size_t i=0;i<
ndim;i++)
peak[i]=p_peak[i];
1166 double sqrt_det=1.0;
1167 for(
size_t i=0;i<
ndim;i++) {
1168 if (!std::isfinite(
chol(i,i))) {
1169 O2SCL_ERR2(
"An entry of the Cholesky decomposition was not finite ",
1172 sqrt_det*=
chol(i,i);
1173 for(
size_t j=0;j<
ndim;j++) {
1174 if (i<j)
chol(i,j)=0.0;
1180 if (!std::isfinite(
norm)) {
1189 void set_alt(
size_t p_ndim, vec_t &p_peak, mat_t &p_chol,
1190 mat_t &p_covar_inv,
double p_norm) {
1216 template<
class vec_vec_t,
class mat_col_t,
class func_t>
1218 vec_vec_t &x, vec_t &y, func_t &fcovar) {
1222 mat_t KXsX(n_dim,n_init);
1223 for(
size_t irow=n_init;irow<n_dim+n_init;irow++) {
1224 for(
size_t icol=0;icol<n_init;icol++) {
1225 KXsX(irow-n_init,icol)=fcovar(x[irow],x[icol]);
1229 mat_t KXXs=boost::numeric::ublas::trans(KXsX);
1231 mat_t KXX(n_init,n_init);
1232 for(
size_t irow=0;irow<n_init;irow++) {
1233 for(
size_t icol=0;icol<n_init;icol++) {
1235 KXX(irow,icol)=KXX(icol,irow);
1237 KXX(irow,icol)=fcovar(x[irow],x[icol]);
1242 mat_t KXsXs(n_dim,n_dim);
1243 for(
size_t irow=n_init;irow<n_dim+n_init;irow++) {
1244 for(
size_t icol=n_init;icol<n_dim+n_init;icol++) {
1246 KXsXs(irow-n_init,icol-n_init)=KXsXs(icol-n_init,irow-n_init);
1248 KXsXs(irow-n_init,icol-n_init)=fcovar(x[irow],x[icol]);
1254 mat_t inv_KXX(n_init,n_init);
1260 "prob_dens_mdim_gaussian::set_gproc().",
1263 o2scl_linalg::LU_invert<mat_t,mat_t,mat_col_t>(n_init,KXX,p,inv_KXX);
1266 vec_t prod(n_init), mean(n_dim);
1267 boost::numeric::ublas::axpy_prod(inv_KXX,y,prod,
true);
1268 boost::numeric::ublas::axpy_prod(KXsX,prod,mean,
true);
1271 mat_t covar(n_dim,n_dim), prod2(n_init,n_dim), prod3(n_dim,n_dim);
1272 boost::numeric::ublas::axpy_prod(inv_KXX,KXXs,prod2,
true);
1273 boost::numeric::ublas::axpy_prod(KXsX,prod2,prod3,
true);
1277 this->
set(n_dim,mean,covar);
1282 virtual double pdf(
const vec_t &x)
const {
1284 O2SCL_ERR2(
"Distribution not set in prob_dens_mdim_gaussian::",
1288 for(
size_t i=0;i<
ndim;i++) {
1292 ret*=exp(-0.5*inner_prod(
q,
vtmp));
1299 O2SCL_ERR2(
"Distribution not set in prob_dens_mdim_gaussian::",
1302 double ret=log(
norm);
1303 for(
size_t i=0;i<
ndim;i++)
q[i]=x[i]-
peak[i];
1305 ret+=-0.5*inner_prod(
q,
vtmp);
1312 O2SCL_ERR2(
"Distribution not set in prob_dens_mdim_gaussian::",
1315 for(
size_t i=0;i<
ndim;i++)
q[i]=
pdg();
1332 template<
class vec_t=boost::numeric::ublas::vector<
double>,
1333 class mat_t=boost::numeric::ublas::matrix<
double> >
1363 vec_t &p_low, vec_t &p_high) {
1364 set(p_ndim,p_peak,covar,p_low,p_high);
1374 void set(
size_t p_ndim, vec_t &p_peak, mat_t &covar,
1375 vec_t &p_low, vec_t &p_high) {
1385 virtual double pdf(
const vec_t &x)
const {
1386 for(
size_t i=0;i<this->
ndim;i++) {
1388 O2SCL_ERR(
"Parameter too small in pdf().",
1392 O2SCL_ERR(
"Parameter too large in pdf().",
1403 for(
size_t i=0;i<this->
ndim;i++) {
1405 O2SCL_ERR(
"Parameter too small in log_pdf().",
1409 O2SCL_ERR(
"Parameter too large in log_pdf().",
1421 while (done==
false) {
1425 for(
size_t i=0;i<this->
ndim;i++) {
1431 }
else if (x[i]>
high[i]) {
1440 "prob_dens_mdim_bound_gaussian::operator().",
1464 template<
class vec_t=boost::numeric::ublas::vector<
double> >
1477 virtual double pdf(
const vec_t &x_B,
const vec_t &x_A)
const=0;
1482 virtual double log_pdf(
const vec_t &x_B,
const vec_t &x_A)
const=0;
1485 virtual void operator()(
const vec_t &x_B, vec_t &x_A)
const=0;
1526 double val1=
log_pdf(x_prime,x);
1527 double val2=
log_pdf(x,x_prime);
1528 if (!std::isfinite(val1)) {
1529 std::cout <<
"val1: " << val1 << std::endl;
1530 O2SCL_ERR(
"Log pdf not finite in log_metrop_hast 1.",
1533 if (!std::isfinite(val2)) {
1534 std::cout <<
"val2: " << val2 << std::endl;
1535 O2SCL_ERR(
"Log pdf not finite in log_metrop_hast 2.",
1585 template<
class vec_t=boost::numeric::ublas::vector<
double> >
1617 for(
size_t i=0;i<sz;i++) {
1620 if (!std::isfinite(low[i]) || !std::isfinite(high[i])) {
1621 O2SCL_ERR2(
"Limit not finite in prob_cond_mdim_fixed_step::",
1626 if (low[i]>high[i]) {
1672 (vec_t &step, vec_t &low, vec_t &high) {
1673 if (step.size()!=low.size()) {
1674 O2SCL_ERR2(
"Vectors 'step' and 'low' mismatched in ",
1675 "prob_cond_mdim_fixed_step constructor.",
1678 if (step.size()!=high.size()) {
1679 O2SCL_ERR2(
"Vectors 'step' and 'high' mismatched in ",
1680 "prob_cond_mdim_fixed_step constructor.",
1688 virtual int set(vec_t &step, vec_t &low, vec_t &high) {
1689 if (step.size()!=low.size()) {
1690 O2SCL_ERR2(
"Vectors 'step' and 'low' mismatched in ",
1691 "prob_cond_mdim_fixed_step::set().",
1694 if (step.size()!=high.size()) {
1695 O2SCL_ERR2(
"Vectors 'step' and 'high' mismatched in ",
1696 "prob_cond_mdim_fixed_step::set().",
1711 virtual double pdf(
const vec_t &x_B,
const vec_t &x_A)
const {
1713 for(
size_t i=0;i<
u_step.size();i++) {
1715 if (fabs(x_A[i]-x_B[i])>
u_step[i])
return 0.0;
1742 virtual double log_pdf(
const vec_t &x_B,
const vec_t &x_A)
const {
1743 return log(
pdf(x_B,x_A));
1749 for(
size_t i=0;i<nv;i++) {
1751 std::cout <<
"Input out of bounds in fixed_step::operator(): "
1752 << i <<
" " << x_B[i] <<
" "
1754 O2SCL_ERR(
"Input out of bounds in fixed_step::operator().",
1777 template<
class vec_t=boost::numeric::ublas::vector<
double> >
1814 virtual double pdf(
const vec_t &x_B,
const vec_t &x_A)
const {
1815 return base.
pdf(x_A);
1821 virtual double log_pdf(
const vec_t &x_B,
const vec_t &x_A)
const {
1843 template<
class vec_t=boost::numeric::ublas::vector<
double>,
1844 class mat_t=boost::numeric::ublas::matrix<
double> >
1921 void set(
size_t p_ndim, mat_t &covar) {
1923 O2SCL_ERR(
"Zero dimension in prob_cond_mdim_gaussian::set().",
1940 double sqrt_det=1.0;
1941 for(
size_t i=0;i<
ndim;i++) {
1942 if (!std::isfinite(
chol(i,i))) {
1943 O2SCL_ERR2(
"An entry of the Cholesky decomposition was not finite ",
1946 sqrt_det*=
chol(i,i);
1947 for(
size_t j=0;j<
ndim;j++) {
1948 if (i<j)
chol(i,j)=0.0;
1954 if (!std::isfinite(
norm)) {
1963 virtual double pdf(
const vec_t &x_B,
const vec_t &x_A)
const {
1965 O2SCL_ERR2(
"Distribution not set in prob_cond_mdim_gaussian::",
1969 for(
size_t i=0;i<
ndim;i++)
q[i]=x_A[i]-x_B[i];
1971 ret*=exp(-0.5*inner_prod(
q,
vtmp));
1978 virtual double log_pdf(
const vec_t &x_B,
const vec_t &x_A)
const {
1980 O2SCL_ERR2(
"Distribution not set in prob_cond_mdim_gaussian::",
1983 double ret=log(
norm);
1984 for(
size_t i=0;i<
ndim;i++)
q[i]=x_A[i]-x_B[i];
1986 ret+=-0.5*inner_prod(
q,
vtmp);
2000 O2SCL_ERR2(
"Distribution not set in prob_cond_mdim_gaussian::",
2003 for (
size_t i=0;i<
ndim;i++)
q[i]=
pdg();
2005 for (
size_t i=0;i<
ndim;i++) x_A[i]=x_B[i]+
vtmp[i];
2016 #ifdef O2SCL_NEVER_DEFINED
2023 template<
class vec_t=boost::numeric::ublas::vector<
double>,
2024 class mat_t=boost::numeric::ublas::matrix<
double>,
2025 class mat_col_t=boost::numeric::ublas::matrix_column<mat_t> >
2026 class prob_dens_mdim_gproc :
2034 #ifndef DOXYGEN_NO_O2NS
virtual double log_pdf(double x) const
The log of the normalized density.
size_t samp_max
Maximum number of samples.
A one-dimensional histogram class.
A one-dimensional probability density over the positive real numbers.
const mat_t & get_chol()
Get the Cholesky decomposition.
virtual double entropy() const
Entropy of the distribution ( )
virtual size_t dim() const
The dimensionality.
mat_t covar_inv
Inverse of the covariance matrix.
prob_dens_mdim_gaussian(const prob_dens_mdim_gaussian &pdmg_loc)
Copy constructor.
prob_dens_mdim_bound_gaussian()
Create an empty distribution.
virtual double log_pdf(double x) const
The log of the normalized density.
Random number generator (GSL)
virtual double log_pdf(const vec_t &x_B, const vec_t &x_A) const
The log of the conditional probability of x_A given x_B i.e. .
virtual size_t dim() const
The dimensionality.
int set_internal(size_t sz, vec_t &step, vec_t &low, vec_t &high)
Internal set function.
const ubvector & partial_sums()
Get reference to partial sums.
prob_dens_lognormal()
Create a blank lognormal distribution.
virtual size_t dim() const
The dimensionality.
virtual double log_metrop_hast(const vec_t &x, vec_t &x_prime) const
Sample the distribution and return the log of the Metropolis-Hastings ratio.
vec_t vtmp
Temporary storage 2.
virtual double entropy() const
Entropy of the distribution ( )
virtual void operator()(vec_t &x) const
Sample the distribution.
virtual double pdf(double x) const
The normalized density.
rng_gsl rg
Internal random number generator.
prob_dens_gaussian()
Create a standard normal distribution.
Probability density function based on a histogram.
A class for representing permutations.
virtual double lower_limit() const
Lower limit of the range.
void set_seed(unsigned long int s)
Set the seed.
virtual double pdf(double x) const
The normalized density.
@ exc_efailed
generic failure
virtual double operator()() const
Sample from the specified density.
void set(size_t p_ndim, vec_t &p_peak, mat_t &covar, vec_t &p_low, vec_t &p_high)
Set the peak, covariance matrix, lower limits, and upper limits.
virtual void operator()(const vec_t &x_B, vec_t &x_A) const
Sample the distribution.
const vec_t & get_peak()
Get the peak location.
prob_dens_mdim_biv_gaussian(const prob_dens_mdim_biv_gaussian &pdmbg)
Copy constructor.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
Lognormal density function.
virtual double log_pdf(const vec_t &x_B, const vec_t &x_A) const =0
The log of the conditional probability of x_A given x_B i.e. .
double y0
The y coordinate of the centroid.
std::vector< double > u_high
Upper limits.
virtual void operator()(vec_t &x) const
Sample the distribution.
const mat_t & get_covar_inv()
Get the inverse of the covariance matrix.
virtual size_t dim() const
The dimensionality.
virtual size_t dim() const
The dimensionality.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
A bivariate gaussian probability distribution.
vec_t vtmp
Temporary storage 2.
prob_dens_gaussian(const prob_dens_gaussian &pdg)
Copy constructor.
A multi-dimensional conditional probability density function independent of the input.
virtual double cdf(double x) const
The cumulative distribution function (from the lower tail)
virtual double log_pdf(const vec_t &x_B, const vec_t &x_A) const
The log of the conditional probability of x_A given x_B i.e. .
double wvector_covariance(size_t n, const vec_t &data1, const vec2_t &data2, const vec3_t &weights)
The weighted covariance of two vectors.
int LU_decomp(const size_t N, mat_t &A, o2scl::permutation &p, int &signum)
Compute the LU decomposition of the matrix A.
virtual double operator()() const
Sample from the specified density.
prob_dens_mdim_gaussian(size_t p_ndim, vec_t &p_peak, mat_t &covar)
Create a distribution from the covariance matrix.
virtual double pdf(const vec_t &x) const
The normalized density.
virtual double log_pdf(double x) const
The log of the normalized density.
A multi-dimensional conditional probability density function.
virtual double pdf(const vec_t &x_B, const vec_t &x_A) const
The conditional probability of x_A given x_B, i.e. .
virtual void operator()(const vec_t &x_B, vec_t &x_A) const
Sample the distribution.
prob_dens_lognormal & operator=(const prob_dens_lognormal &pdg)
Copy constructor with operator=.
virtual size_t dim() const
Return the dimensionality.
void set_gproc(size_t n_dim, size_t n_init, vec_vec_t &x, vec_t &y, func_t &fcovar)
Given a data set and a covariance function, construct probability distribution based on a Gaussian pr...
@ exc_eunimpl
requested feature not (yet) implemented
virtual double level_fixed_integral(double integral)
Return the contour level corresponding to a fixed integral.
virtual double log_pdf(const vec_t &x) const
The log of the normalized density.
virtual double pdf(const vec_t &x_B, const vec_t &x_A) const =0
The conditional probability of x_A given x_B, i.e. .
void set(size_t p_ndim, vec_t &p_peak, mat_t &covar)
Set the peak and covariance matrix for the distribution.
virtual double cdf(double x) const
Cumulative distribution function (from the lower tail)
int set(size_t p_mdim, size_t n_pts, const mat2_t &pts, const vec2_t &vals, vec_t &peak_arg, mat_t &covar_arg)
Create a distribution from a set of samples from a multidimensional Gaussian, returning the peak valu...
virtual double log_pdf(const vec_t &x) const
Compute the natural log of the probability density function (arbitrary normalization)
double stddev()
Get the Gaussian width.
A one-dimensional probability density over a finite range.
virtual double cdf(double x) const
The cumulative distribution function (from the lower tail)
mat_t chol
Cholesky decomposition.
ubvector range
Vector specifying original histogram bins.
void set_center(double cent)
Set the center.
double sigma_
Width parameter.
double norm
Normalization factor.
prob_cond_mdim_gaussian()
Create an empty distribution.
const ubvector & bin_ranges()
Get reference to bin ranges.
double random()
Return a random number in .
void set_seed(unsigned long int s)
Set the seed.
virtual double upper_limit() const =0
Uower limit of the range.
size_t ndim
Number of dimensions.
prob_cond_mdim_fixed_step & operator=(const prob_cond_mdim_fixed_step &pcmfs)
Copy constructor with operator=.
std::vector< prob_dens_func > list
Vector of one-dimensional distributions.
vec_t q
Temporary storage 1.
o2scl::prob_dens_gaussian pdg
Standard normal.
std::vector< double > u_step
Step sizes.
virtual int set(vec_t &step, vec_t &low, vec_t &high)
Set step sizes and limits.
virtual void operator()(const vec_t &x_B, vec_t &x_A) const
Sample the distribution.
virtual double invert_cdf(double x) const
Inverse cumulative distribution function (from the lower tail)
virtual void operator()(vec_t &x) const
Sample the distribution.
prob_dens_mdim_factor(const prob_dens_mdim_factor &pdmf)
Copy constructor.
@ exc_einval
invalid argument supplied by user
virtual double pdf(const vec_t &v) const
Compute the normalized probability density.
virtual double pdf(const vec_t &x) const
The normalized density.
virtual double log_pdf(const vec_t &x_B, const vec_t &x_A) const
The log of the conditional probability of x_A given x_B i.e. .
ubvector sum
Normalized partial sum of histogram bins.
void set(size_t p_ndim, mat_t &covar)
Set the covariance matrix for the distribution.
void set(double x_cent, double y_cent, double x_std, double y_std, double covar)
Set the properties of the distribution.
search_vec< ubvector > sv
Search through the partial sums.
prob_cond_mdim_gaussian(const prob_cond_mdim_gaussian &pcmg)
Copy constructor.
int cholesky_decomp(const size_t M, mat_t &A, bool err_on_fail=true)
Compute the in-place Cholesky decomposition of a symmetric positive-definite square matrix.
virtual double operator()() const
Generate a sample.
prob_dens_gaussian & operator=(const prob_dens_gaussian &pdg)
Copy constructor with operator=.
double sigma_
Width parameter.
virtual double log_pdf(const vec_t &x) const
The log of the normalized density.
const double & get_norm()
Get the normalization.
void set_seed(unsigned long int s)
Set the seed.
prob_cond_mdim_indep(prob_dens_mdim< vec_t > &out)
Create a conditional probability distribution based on the specified probability distribution.
void set_seed(unsigned long int s)
Set the seed.
Generic object which represents a column of a const matrix.
virtual void operator()(const vec_t &x_B, vec_t &x_A) const =0
Sample the distribution.
mat_t chol
Cholesky decomposition.
virtual void operator()(vec_t &x) const
Sample the distribution.
virtual double operator()() const
Sample from the specified density.
virtual size_t dim() const
Return the dimensionality.
virtual double invert_cdf(double in_cdf) const
The inverse cumulative distribution function.
Searching class for monotonic data with caching.
Gaussian distribution bounded by a hypercube.
virtual double cdf(double x) const
The cumulative distribution function (from the lower tail)
prob_dens_mdim_gaussian & operator=(const prob_dens_mdim_gaussian &pdmg_loc)
Copy constructor with operator=.
prob_cond_mdim_fixed_step(const prob_cond_mdim_fixed_step &pcmfs)
Copy constructor.
mat_t covar_inv
Inverse of the covariance matrix.
void set_seed(unsigned long int s)
Set the random number generator seed.
void set_sigma(double sigma)
Set the Gaussian width (must be positive)
virtual double pdf(const vec_t &x_B, const vec_t &x_A) const
The conditional probability of x_A given x_B, i.e. .
A multi-dimensional Gaussian conditional probability density function.
virtual double pdf(const vec_t &x) const
Compute the probability density function (arbitrary normalization)
A multi-dimensional probability density function.
virtual double entropy() const
Entropy of the distribution ( )
o2scl::rng_gsl r
Base GSL random number generator.
prob_dens_mdim_gaussian()
Create an empty distribution.
A multi-dimensional Gaussian probability density function using a Cholesky decomposition.
void init(hist &h)
Initialize with histogram h.
size_t n
Number of original histogram bins.
size_t ndim
Number of dimensions.
Conditional probability for a random walk inside a hypercube.
virtual void contour(double level, double theta, vec_t &x)
Return a point on the contour for a specified level given an angle.
virtual double log_pdf(double x) const
The log of the normalized density.
vec_t q
Temporary storage 1.
prob_cond_mdim_gaussian(size_t p_ndim, mat_t &covar)
Create a distribution from the covariance matrix.
double mean()
Get the center.
double sig_y
The y standard deviation.
std::vector< double > u_low
Lower limits.
int set(size_t p_mdim, size_t n_pts, const mat2_t &pts, const vec2_t &vals)
Create a distribution from a set of samples from a multidimensional Gaussian.
virtual double pdf(double x) const
The normalized density.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
void set_mu_sigma(double mu, double sigma)
Set the maximum and width of the lognormal distribution.
virtual double lower_limit() const =0
Lower limit of the range.
A one-dimensional Gaussian probability density.
virtual double invert_cdf(double cdf) const
The inverse cumulative distribution function.
prob_cond_mdim_indep & operator=(const prob_cond_mdim_indep &pcmi)
Copy constructor with operator=.
rng_gsl r
The GSL random number generator.
o2scl::prob_dens_gaussian pdg
Standard normal.
A one-dimensional probability density function.
double cent_
Central value.
virtual double pdf(const vec_t &x) const
The normalized density.
prob_dens_mdim_bound_gaussian(size_t p_ndim, vec_t &p_peak, mat_t &covar, vec_t &p_low, vec_t &p_high)
Create a distribution with the specified peak, covariance matrix, lower limits, and upper limits.
prob_dens_lognormal(double mu, double sigma)
Create lognormal distribution with mean parameter mu and width parameter sigma.
prob_dens_gaussian(double cent, double sigma)
Create a Gaussian distribution with width sigma.
virtual double invert_cdf(double in_cdf) const
The inverse cumulative distribution function.
virtual double pdf(double x) const
The normalized density.
double sig_x
The x standard deviation.
vec_t peak
Location of the peak.
prob_cond_mdim_gaussian & operator=(const prob_cond_mdim_gaussian &pcmg)
Copy constructor with operator=.
virtual double pdf(const vec_t &x_B, const vec_t &x_A) const
The conditional probability of x_A given x_B, i.e. .
virtual double log_pdf(const vec_t &x) const
The log of the normalized density.
int diagonal_has_zero(const size_t N, mat_t &A)
Return 1 if at least one of the elements in the diagonal is zero.
rng_gsl rng
Random number generator.
prob_cond_mdim_indep(const prob_cond_mdim_indep &pcmi)
Copy constructor.
virtual double upper_limit() const
Uower limit of the range.
double x0
The x coordinate of the centroid.
virtual double entropy() const
Entropy of the distribution ( )
double norm
Normalization factor, .
A multidimensional distribution formed by the product of several one-dimensional distributions.
prob_dens_lognormal(const prob_dens_lognormal &pdg)
Copy constructor.
void set_alt(size_t p_ndim, vec_t &p_peak, mat_t &p_chol, mat_t &p_covar_inv, double p_norm)
Alternate set function for use when covariance matrix has already been decomposed and inverted.
double rho
The covariance.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).