1.2.3
CCC
 
Law.cpp File Reference
#include "geoslib_old_f.h"
#include "Basic/Law.hpp"
#include "Basic/AException.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/VectorHelper.hpp"
#include <math.h>
#include <random>

Functions

void law_set_old_style (bool style)
 
int law_get_random_seed (void)
 
void law_set_random_seed (int seed)
 
double law_uniform (double mini, double maxi)
 
int law_int_uniform (int mini, int maxi)
 
double law_gaussian (double mean, double sigma)
 
double law_exponential (double lambda)
 
double law_gamma (double alpha, double beta)
 
double law_stable_standard_abgd (double alpha)
 
double law_stable_standard_agd (double alpha, double beta)
 
double law_stable_standard_a1gd (double beta)
 
double law_stable_a (double alpha, double beta, double gamma, double delta)
 
double law_stable_a1 (double beta, double gamma, double delta)
 
double law_stable (double alpha, double beta, double gamma, double delta)
 
double law_beta1 (double parameter1, double parameter2)
 
double law_beta2 (double parameter1, double parameter2)
 
double law_df_gaussian (double value)
 
double law_dnorm (double value, double mean, double std)
 
double law_cdf_gaussian (double value)
 
double law_invcdf_gaussian (double value)
 
double law_gaussian_between_bounds (double binf, double bsup)
 
double law_df_bigaussian (VectorDouble &vect, VectorDouble &mean, MatrixSquareSymmetric &correl)
 
double law_df_quadgaussian (VectorDouble &vect, MatrixSquareSymmetric &correl)
 
double law_df_multigaussian (VectorDouble &vect, MatrixSquareSymmetric &correl)
 
int law_poisson (double parameter)
 
VectorInt law_random_path (int nech)
 
int law_binomial (int n, double p)
 
double * law_exp_sample (double *tabin, int mode, int nvar, int nechin, int nechout, int niter, int nconst, double *consts, int seed, double percent)
 

Variables

std::mt19937 Random_gen
 

Function Documentation

double law_beta1 ( double  parameter1,
double  parameter2 
)

Generate random numbers according to a beta distribution (first kind)

Returns
Beta random value (first kind)
Parameters
[in]parameter1first parameter of the beta distribution
[in]parameter2first parameter of the beta distribution
double law_beta2 ( double  parameter1,
double  parameter2 
)

Generate random numbers according to a beta distribution (second kind)

Returns
Beta random value (second kind)
Parameters
[in]parameter1first parameter of the beta distribution
[in]parameter2first parameter of the beta distribution
int law_binomial ( int  n,
double  p 
)

Generates a binomial value

Returns
The binomial value
Parameters
[in]nNumber of trials
[in]pEvent probability
double law_cdf_gaussian ( double  value)

Cumulated density function of a gaussian distribution

Returns
Gaussian cumulated density function
Parameters
[in]valueraw value
Remarks
Handbook P932 (26.2.17) precision <7.5 E-08
double law_df_bigaussian ( VectorDouble vect,
VectorDouble mean,
MatrixSquareSymmetric correl 
)

Density function of a bigaussian distribution

Returns
Gaussian density function
Parameters
[in]vectArray of values (Dimension = 2)
[in]meanArray of means (Dimension = 2)
[in]correlCorrelation matrix (Dimension: 2*2)
double law_df_gaussian ( double  value)

Density function of a gaussian distribution

Returns
Gaussian density function
Parameters
[in]valueraw value
double law_df_multigaussian ( VectorDouble vect,
MatrixSquareSymmetric correl 
)

Density function of a multigaussian distribution

Returns
Gaussian density function
Parameters
[in]vectArray of values (Dimension = nvar)
[in]correlCorrelation matrix (Dimension: nvar*nvar)
double law_df_quadgaussian ( VectorDouble vect,
MatrixSquareSymmetric correl 
)

Density function of a quadrigaussian distribution

Returns
Gaussian density function
Parameters
[in]vectArray of values (Dimension = nvar)
[in]correlCorrelation matrix (Dimension: nvar*nvar)
double law_dnorm ( double  value,
double  mean,
double  std 
)

Density function of a (non-normalized) gaussian distribution

Returns
Gaussian density function
Parameters
[in]valueRaw value
[in]meanMean value
[in]stdStandard deviation
double* law_exp_sample ( double *  tabin,
int  mode,
int  nvar,
int  nechin,
int  nechout,
int  niter,
int  nconst,
double *  consts,
int  seed,
double  percent 
)

Sample a multivariate empirical distribution

Returns
Address to the newly created array
Parameters
[in]tabinInput array
[in]modeDescribes the way 'tabin' and 'tabout' are filled 1: by column; 2: by row
[in]nvarNumber of variables (input and output)
[in]nechinNumber of samples in the input array
[in]nechoutNumber of created samples
[in]niterMaximum number of iterations
[in]nconstNumber of constraints
[in]constsArray of constraints (optional) (Dimension: nconst * (nvar+1)) This array is entered by line
[in]seedValue for the seed generator
[in]percentDimension of the convolution kernel expressed as a percentage of the dispersion st. dev. Should be between 0 and 100
Remarks
The input array must be isotopic (otherwise, an error is issued)
The resulting array if dimensionned to nvar * nechout
The created (and returned) array must be freed by the calling
function
Consider nvar1 = nvar + 1
Sample temp[1:nvar1] is authorized for Constraint 'iconst' if:
Sum_ivar1^{1:nvar1) consts[iconst,ivar1) * temp[ivar1] > 0
double law_exponential ( double  lambda)

Generate random numbers according to exponential distribution

Returns
Exponential random value
Parameters
[in]lambdaParameter of exponential distribution
double law_gamma ( double  alpha,
double  beta 
)

Generate random numbers according to a gamma distribution

Returns
Gamma random value
Parameters
[in]alphaparameter of the gamma distribution
[in]betaSecond parameter of the Gamma distribution
double law_gaussian ( double  mean,
double  sigma 
)

Generate random numbers according to a gaussian distribution

Returns
Gaussian random value
Parameters
[in]meanMean of the Normal Distribution
[in]sigmaStandard deviation of the Normal Distribution
double law_gaussian_between_bounds ( double  binf,
double  bsup 
)

Generates a gaussian value which lies in an interval

Returns
The gaussian value
Parameters
[in]binflower bound of the interval
[in]bsupupper bound of the interval
int law_get_random_seed ( void  )

read the seed for the random number generator

Returns
The current value of the seed (integer)
int law_int_uniform ( int  mini,
int  maxi 
)

Draw an integer random number according to a uniform distribution

Returns
Integer Uniform random value within an interval
Parameters
[in]miniminimum value
[in]maximaximum value
double law_invcdf_gaussian ( double  value)

Inverse cumulated density function of a gaussian distribution

Returns
Inverse of gaussian cumulated density function
Parameters
[in]valuecumulative density
int law_poisson ( double  parameter)

Generate random number according to a poisson distribution

Returns
Poisson random value
Parameters
[in]parameterparameter of the Poisson distribution
Remarks
Method Ahrens-Dieter (1973)
VectorInt law_random_path ( int  nech)

Define a random path

Parameters
[in]nech: Number of samples
void law_set_old_style ( bool  style)

Set the type of Usage for Random Number Generation

Parameters
styletrue for using Old Style; false for using New Style
void law_set_random_seed ( int  seed)

Sets the seed for the random number generator

Parameters
[in]seedthe new value given to the seed
double law_stable ( double  alpha,
double  beta,
double  gamma,
double  delta 
)

Generate random numbers according to a stable distribution

Returns
Stable value with unit parameters
Parameters
[in]alphavalue of the alpha parameter
[in]betavalue of the beta parameter
[in]gammavalue of the gamma parameter
[in]deltavalue of the delta parameter
double law_stable_a ( double  alpha,
double  beta,
double  gamma,
double  delta 
)

Generate random numbers according to a stable distribution (alpha != 1)

Returns
Stable value with unit parameters
Parameters
[in]alphavalue of the alpha parameter
[in]betavalue of the beta parameter
[in]gammavalue of the gamma parameter
[in]deltavalue of the delta parameter
double law_stable_a1 ( double  beta,
double  gamma,
double  delta 
)

Generate random numbers according to a stable distribution (alpha=1)

Returns
Stable value with unit parameters
Parameters
[in]betavalue of the beta parameter
[in]gammavalue of the gamma parameter
[in]deltavalue of the delta parameter
double law_stable_standard_a1gd ( double  beta)

Generate random numbers according to a standard stable distribution (alpha=1)

Returns
Stable value with standard parameters (alpha=gamma=1,delta=0)
Parameters
[in]betavalue of the beta parameter
double law_stable_standard_abgd ( double  alpha)

Generate random numbers according to a standard stable distribution

Returns
Stable value with std. parameters (beta=gamma=1,delta=0,alpha!=1)
Parameters
[in]alphavalue of the alpha parameter
double law_stable_standard_agd ( double  alpha,
double  beta 
)

Generate random numbers according to a standard stable distribution

Returns
Stable value with standard parameters (gamma=1,delta=0,alpha!=1)
Parameters
[in]alphavalue of the alpha parameter
[in]betavalue of the beta parameter
double law_uniform ( double  mini,
double  maxi 
)

Draw a random number according to a uniform distribution

Returns
Uniform random value within an interval
Parameters
[in]miniminimum value
[in]maximaximum value

Variable Documentation

std::mt19937 Random_gen