4 : mu(mu), sigma_p(sigma_p), sigma_m(sigma_m)
6 N = 2.0 / (sigma_p + sigma_m);
7 w = sigma_m / (sigma_p + sigma_m);
9 gsl_rng_set(eng_.get(), seed);
13 std::vector<double> z(n);
14 for (std::size_t i = 0; i < n; ++i)
15 z[i] =
ppf(gsl_ran_flat(eng_.get(), 0, 1));
20 double sigma_local = x > mu ? sigma_p : sigma_m;
22 return -0.5 * std::pow((x - mu) / sigma_local, 2);
26 double sigma_local = x > mu ? sigma_p : sigma_m;
27 double s2 = sigma_local * sigma_local;
28 double f = N / std::sqrt(2 *
PI) * std::exp(-0.5 * std::pow((x - mu) / sigma_local, 2));
29 double df = -(x - mu) / s2 *
f;
30 double ddf = ((std::pow(x - mu / sigma_local, 2)) - 1) *
f / s2;
37 return 2 * w * gsl_cdf_gaussian_P((x - mu) / sigma_m, 1);
39 return w + 2 * (1 - w) * (gsl_cdf_gaussian_P((x - mu) / sigma_p, 1) - 0.5);
46 u = (1 - 2 * w + p) / (2 * (1 - w));
52 return mu + s * gsl_cdf_gaussian_Pinv(u, 1);
56 return mu + std::sqrt(2 /
PI) * (sigma_p - sigma_m);
60 return std::sqrt((1 - 2 /
PI) * std::pow(sigma_p - sigma_m, 2) + sigma_p * sigma_m);
Asymmetric split-Gaussian marginal distribution.
double logpdf(double x) override
Evaluates the logarithm of the probability density at x.
double cdf(double x) override
Evaluates the cumulative distribution function at x.
double std() override
Returns the standard deviation of the distribution.
double mean() override
Returns the mean of the distribution.
std::vector< double > rvs(std::size_t n) override
Draws random samples from the marginal distribution.
double ppf(double p) override
Evaluates the quantile function (inverse CDF).
SplitGaussianMarginal(double mu, double sigma_p, double sigma_m, unsigned int seed=std::random_device{}())
Constructs an asymmetric split-Gaussian marginal.
PDFDiff f_df_ddf(double x) override
double f(double x)
Wilson special function f depending on x.