Legofit
infers population history from nucleotide site patterns.
|
Pseudorandom numbers from a truncated Gaussian distribution. More...
#include <math.h>
#include <stdio.h>
#include <stdbool.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_sf_erf.h>
#include <assert.h>
#include "dtnorm.h"
#include "dtnorm_data.h"
Functions | |
double | yl (int k) |
double | dtexp (gsl_rng *rng, double a, double b) |
Rejection algorithm with a truncated exponential proposal. | |
double | dtnorm (const double mu, const double sigma, double a, double b, gsl_rng *rng) |
Pseudorandom numbers from a truncated Gaussian distribution. More... | |
Variables | |
int | N = 4001 |
Pseudorandom numbers from a truncated Gaussian distribution.
This code began with C++ original written by G. Dolle and V Mazet, which is available at http://miv.u-strasbg.fr/mazet/rtnorm/rtnormCpp.zip. That original code implemented several methods, including Chopin's algorithm (2011. Stat Comput. 21:275-288). Different methods were used in different regions of parameter space.
My own numerical experiments indicated that this method can be improved by changing the criteria used in selecting algorithms. In some regions of parameter space, it is best to use Robert's method (1995. Statistics and Computing, 5(2):121). The current code implements the revised method in C.
Copyright (C) 2012 Guillaume Dollé, Vincent Mazet (LSIIT, CNRS/Université de Strasbourg) Version 2012-07-04, Contact: vince.nosp@m.nt.m.nosp@m.azet@.nosp@m.unis.nosp@m.tra.f.nosp@m.r
06/07/2012:
Licence: GNU General Public License Version 2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Depends: LibGSL OS: Unix based system
double dtnorm | ( | const double | mu, |
const double | sigma, | ||
double | a, | ||
double | b, | ||
gsl_rng * | rng | ||
) |
Pseudorandom numbers from a truncated Gaussian distribution.
[in] | mu | mean of underlying Gaussian distribution. |
[in] | sigma | standard deviation of underlying Gaussian |
[in] | a | lower end of truncation interval |
[in] | b | upper end of truncation interval |
[in,out] | rng | GSL random number generator |