1.3.2
CCC
 
Law.cpp File Reference
#include "geoslib_old_f.h"
#include "Basic/Law.hpp"
#include "Basic/AException.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/MathFunc.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)
 
VectorDouble law_df_poisson_vec (VectorInt is, double parameter)
 
double law_df_poisson (int i, double parameter)
 
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)
 
int sampleInteger (int mini, int maxi)
 

Variables

std::mt19937 Random_gen
 

Function Documentation

◆ law_beta1()

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

◆ law_beta2()

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

◆ law_binomial()

int law_binomial ( int  n,
double  p 
)

Generates a binomial value

Returns
The binomial value
Parameters
[in]nNumber of trials
[in]pEvent probability

◆ law_cdf_gaussian()

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

◆ law_df_bigaussian()

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)

◆ law_df_gaussian()

double law_df_gaussian ( double  value)

Density function of a gaussian distribution

Returns
Gaussian density function
Parameters
[in]valueraw value

◆ law_df_multigaussian()

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)

◆ law_df_poisson()

double law_df_poisson ( int  i,
double  parameter 
)

◆ law_df_poisson_vec()

VectorDouble law_df_poisson_vec ( VectorInt  is,
double  parameter 
)

◆ law_df_quadgaussian()

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)

◆ law_dnorm()

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

◆ law_exp_sample()

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

◆ law_exponential()

double law_exponential ( double  lambda)

Generate random numbers according to exponential distribution

Returns
Exponential random value
Parameters
[in]lambdaParameter of exponential distribution

◆ law_gamma()

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

◆ law_gaussian()

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

◆ law_gaussian_between_bounds()

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

◆ law_get_random_seed()

int law_get_random_seed ( void  )

read the seed for the random number generator

Returns
The current value of the seed (integer)

◆ law_int_uniform()

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

◆ law_invcdf_gaussian()

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

◆ law_poisson()

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)

◆ law_random_path()

VectorInt law_random_path ( int  nech)

Define a random path

Parameters
[in]nech: Number of samples

◆ law_set_old_style()

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

◆ law_set_random_seed()

void law_set_random_seed ( int  seed)

Sets the seed for the random number generator

Parameters
[in]seedthe new value given to the seed

◆ law_stable()

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

◆ law_stable_a()

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

◆ law_stable_a1()

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

◆ law_stable_standard_a1gd()

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

◆ law_stable_standard_abgd()

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

◆ law_stable_standard_agd()

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

◆ law_uniform()

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

◆ sampleInteger()

int sampleInteger ( int  mini,
int  maxi 
)

Returns an integer sampled uniformly wihtin the interval [mini, maxi]

Parameters
miniLower bound (included)
maxiUpper bound (included)

Variable Documentation

◆ Random_gen

std::mt19937 Random_gen