14 #ifndef PROB_CONDITIONAL_DISTRIBUTION_H_INCLUDED
15 #define PROB_CONDITIONAL_DISTRIBUTION_H_INCLUDED
61 template<
class TargetVariable,
class GivenVariable,
class DependenceFunc>
65 DependenceFunc depfunc;
103 template<
class Target,
class Given,
class Func>
118 template<
class Target,
class Given,
class Func>
133 template<
class Target,
class Given,
class Func>
177 cov_XY(covariance_XY)
187 X(0, sqrt(conditional_std_dev * conditional_std_dev + 1)),
204 cov_XY = nond.cov_XY;
212 double var_X = X.standard_deviation() * X.standard_deviation();
213 double var_Y = Y.standard_deviation() * Y.standard_deviation();
215 double mu = X.mean() + ((cov_XY / var_Y) * (y - Y.mean()));
216 double sigma = var_X - ((cov_XY * cov_XY) / var_Y);
257 const Matrix& covariance_XY
261 cov_XY(covariance_XY)
276 X(
Vector(conditional_cov.get_num_rows(), 0.0),
294 cov_XY = nond.cov_XY;
Distribution_traits< Target >::type conditional_sample(const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Given >::type &y)
Produces a sample from the given conditioanl distro, given a value for the given variable.
Definition: prob_conditional_distribution.h:135
Represents the dependence between X and Y in p(x | y), where (x,y) is a multivariate normal...
Definition: prob_conditional_distribution.h:246
Normal_on_normal_dependence(double conditional_std_dev)
Specify this conditional distributon by specifying the conditional variance, meaning the mean will si...
Definition: prob_conditional_distribution.h:186
const Matrix & get_covariance_matrix() const
Gets the covariance matrix of this distribution.
Definition: prob_distribution.h:689
Conditional_distribution< MV_normal_distribution, MV_normal_distribution, MV_normal_on_normal_dependence > MV_normal_conditional_distribution
Definition: prob_conditional_distribution.h:321
Definition of various standard probability distributions.
double conditional_pdf(const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Target >::type &x, const typename Distribution_traits< Given >::type &y)
Gets the conditional pdf p(x | y) of the given ConditionalDistribution.
Definition: prob_conditional_distribution.h:105
MV_gaussian_distribution MV_normal_distribution
Definition: prob_distribution.h:813
Object thrown when an argument is of the wrong size or dimensions.
Definition: l_exception.h:426
Normal_conditional_distribution Gaussian_conditional_distribution
Definition: prob_conditional_distribution.h:230
int get_num_rows() const
Return the number of rows in the matrix.
Definition: m_matrix.h:543
Conditional_distribution & operator=(const Conditional_distribution &cd)
Definition: prob_conditional_distribution.h:79
MV_normal_on_normal_dependence(const Matrix &conditional_cov, int dim_y)
Specify this conditional distributon by specifying the conditional variance, meaning the mean will si...
Definition: prob_conditional_distribution.h:275
MV_normal_on_normal_dependence & operator=(const MV_normal_on_normal_dependence &nond)
Definition: prob_conditional_distribution.h:288
Conditional_distribution(const Conditional_distribution &cd)
Definition: prob_conditional_distribution.h:75
Normal_on_normal_dependence(const Normal_distribution &PX, const Normal_distribution &PY, double covariance_XY)
Specify this conditional distributon by specifying the marginals and the covariance.
Definition: prob_conditional_distribution.h:170
Normal_on_normal_dependence(const Normal_on_normal_dependence &nond)
Definition: prob_conditional_distribution.h:192
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
double pdf(const MV_gaussian_distribution &P, const Vector &x)
Computes the joint PDF of a multivariate Gaussian at x.
Definition: prob_pdf.cpp:32
Vector sample(const MV_gaussian_distribution &dist)
Sample from a multivariate normal distribution.
Definition: prob_sample.cpp:42
double conditional_log_pdf(const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Target >::type &x, const typename Distribution_traits< Given >::type &y)
Gets the conditional log-pdf log p(x | y) of the given ConditionalDistribution.
Definition: prob_conditional_distribution.h:120
Matrix matrix_inverse(const Matrix &op1)
Invert this matrix.
Definition: m_matrix.cpp:730
int get_num_cols() const
Return the number of columns in the matrix.
Definition: m_matrix.h:554
Int_matrix matrix_transpose(const Int_matrix &op1)
Test for any difference between two matrices.
Definition: l_int_matrix.h:1331
int get_dimension() const
Gets the dimension of this distribution.
Definition: prob_distribution.h:743
MV_normal_conditional_distribution MV_gaussian_conditional_distribution
Definition: prob_conditional_distribution.h:323
PDFs and CDFs for the different distributions defined in "prob_distribution.h".
double type
Definition: prob_distribution.h:111
A conditional distribution.
Definition: prob_conditional_distribution.h:62
x
Definition: APPgetLargeConnectedEdges.m:100
Distribution_traits< GivenVariable >::type given_type
Definition: prob_conditional_distribution.h:69
double log_pdf(const MV_gaussian_distribution &P, const Vector &x)
Computes the log PDF a multivariate normal distribution at x.
Definition: prob_pdf.cpp:64
MV_normal_on_normal_dependence(const MV_normal_distribution &PX, const MV_normal_distribution &PY, const Matrix &covariance_XY)
Specify this conditional distributon by specifying the marginals and the covariance.
Definition: prob_conditional_distribution.h:254
Multivariate Gaussian (normal) distribution.
Definition: prob_distribution.h:619
Normal_on_normal_dependence & operator=(const Normal_on_normal_dependence &nond)
Definition: prob_conditional_distribution.h:198
Matrix create_identity_matrix(int rank)
Construct an identity matrix of specified rank.
Definition: m_matrix.h:1795
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
Conditional_distribution(DependenceFunc f)
Definition: prob_conditional_distribution.h:71
Normal_on_normal_dependence Gaussian_on_gaussian_dependence
Definition: prob_conditional_distribution.h:226
boost::math::normal Normal_distribution
Definition: prob_distribution.h:68
Sampling functionality for the different distributions defined in "prob_distributions.h".
MV_normal_on_normal_dependence(const MV_normal_on_normal_dependence &nond)
Definition: prob_conditional_distribution.h:282
Represents the dependence between X and Y in p(x | y), where (x,y) is a bivariate normal...
Definition: prob_conditional_distribution.h:162
MV_normal_distribution operator()(const Vector &y) const
Definition: prob_conditional_distribution.h:300
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
const Vector & get_mean() const
Gets the mean of this distribution.
Definition: prob_distribution.h:681
MV_normal_on_normal_dependence MV_gaussian_on_gaussian_dependence
Definition: prob_conditional_distribution.h:319
Conditional_distribution< Normal_distribution, Normal_distribution, Normal_on_normal_dependence > Normal_conditional_distribution
Definition: prob_conditional_distribution.h:228
TargetVariable get_distribution(const given_type &y) const
Gets the distribution when we fix the given variable; i.e., it applies the dependence function to y...
Definition: prob_conditional_distribution.h:93
Normal_distribution operator()(double y) const
Definition: prob_conditional_distribution.h:210
Distribution_traits< TargetVariable >::type target_type
Definition: prob_conditional_distribution.h:68