![]() |
![]() |
![]() |
liboscats Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
guint32 oscats_rnd_uniform_int (); gint oscats_rnd_uniform_int_range (gint min
,gint max
); gdouble oscats_rnd_uniform (); gdouble oscats_rnd_uniform_range (gdouble min
,gdouble max
); gdouble oscats_rnd_normal (gdouble sd
); void oscats_rnd_binorm (gdouble sdx
,gdouble sdy
,gdouble rho
,gdouble *X
,gdouble *Y
); void oscats_rnd_multinorm_prep (const GGslMatrix *sigma
,GGslMatrix *sigma_half
); void oscats_rnd_multinorm (const GGslVector *mu
,const GGslMatrix *sigma_half
,GGslVector *x
); gdouble oscats_rnd_exp (gdouble mu
); gdouble oscats_rnd_gamma (gdouble a
,gdouble b
); gdouble oscats_rnd_beta (gdouble a
,gdouble b
); void oscats_rnd_dirichlet (const GGslVector *alpha
,GGslVector *x
); guint oscats_rnd_poisson (gdouble mu
); guint oscats_rnd_binomial (guint n
,gdouble p
); void oscats_rnd_multinomial (guint n
,const GGslVector *p
,GArray *x
); guint oscats_rnd_hypergeometric (guint n1
,guint n2
,guint N
); gdouble oscats_rnd_normal_p (gdouble x
,gdouble sd
); gdouble oscats_rnd_chisq_p (gdouble x
,gdouble nu
); gdouble oscats_rnd_F_p (gdouble x
,gdouble nu1
,gdouble nu2
); gdouble oscats_rnd_t_p (gdouble x
,gdouble nu
); void oscats_rnd_sample (const GPtrArray *population
,guint num
,GPtrArray *sample
,gboolean replace
);
guint32 oscats_rnd_uniform_int ();
Returns : |
a uniformly random integer on [0, 2^32) |
gint oscats_rnd_uniform_int_range (gint min
,gint max
);
|
the minimum |
|
the maximum |
Returns : |
a uniformly random integer on [min , max ] |
gdouble oscats_rnd_uniform_range (gdouble min
,gdouble max
);
|
minimum |
|
maximum |
Returns : |
a uniformly random number on [min ,max ). |
gdouble oscats_rnd_normal (gdouble sd
);
The mean-zero normal distribution has pdf f_norm(x|sd) = exp(-x^2 / (2 sd^2)) / (sqrt(2 pi) sd).
Must have: sd
> 0.
|
standard deviation |
Returns : |
a Normally distributed random number |
void oscats_rnd_binorm (gdouble sdx
,gdouble sdy
,gdouble rho
,gdouble *X
,gdouble *Y
);
The mean-zero bivariate normal distribution has pdf f_binorm(x,y|sdx,sdy) = exp(-(x^2/sdx^2 + y^2/sdy^2 - 2 rho x y / (sdx sdy)) / 2(1-rho^2)) / (2 pi sdx sdy). Note that cov(X,Y) = rho * sdx * sdy.
Must have: sdx
> 0, sdy
> 0, -1 <= rho
<= 1.
|
standard deviation for first variable |
|
standard deviation for second variable |
|
correlation coefficient |
|
pointer to return first variable |
|
pointer to return second variable |
void oscats_rnd_multinorm_prep (const GGslMatrix *sigma
,GGslMatrix *sigma_half
);
Prepares a lower-triangular matrix A such that AA'=Sigma for multivariate-normal random-number generation. This is achieved by Cholesky decomposition.
Must have: sigma
symmetric and positive definite,
sigma
and sigma_half
with same size > 2.
|
covariance matrix for multivariate normal distribution |
|
return matrix |
void oscats_rnd_multinorm (const GGslVector *mu
,const GGslMatrix *sigma_half
,GGslVector *x
);
A random vector x
of length n
is multivariate normal if
x
= mu
+ A
z
, where AA' = Sigma is the covariance matrix of the
random vector, and z
is a vector of indepenedent standard normal
random variables.
Must have: sigma_half
lower-triangular with same size as mu
and x
.
|
mean |
|
half of covariance matrix |
|
return for random vector |
gdouble oscats_rnd_normal_p (gdouble x
,gdouble sd
);
Computes the upper tail of the Normal cdf: p_norm(x|sd) = int_{-\infty}^x f_norm(t|sd) dt.
Must have: sd
> 0.
|
sampled value |
|
standard deviation |
Returns : |
the upper-tail p-value |
gdouble oscats_rnd_chisq_p (gdouble x
,gdouble nu
);
If y_1, ..., y_nu are standard normally distributed random numbers,
then sum_1^nu y_i^2 is distributed Chi^2 with nu degrees of freedom.
Computes the upper tail of the Chi^2 cdf with nu
degrees of freedom:
p_chisq(x|nu) = int_{-\infty}^x (t/2)^(nu^2-1) exp(-t/2) / 2 Gamma(nu/2) dt.
Must have: x
>= 0.
|
sampled value |
|
degrees of freedom |
Returns : |
the upper-tail p-value |
gdouble oscats_rnd_F_p (gdouble x
,gdouble nu1
,gdouble nu2
);
If y_1 is distributed Chi^2 with nu_1 degrees of freedom, and
y_2 is distributed Chi^2 with nu_2 degrees of freedom,
w = (y_1/nu_1) / (y_2/nu_2) is distributed F(nu_1, nu_2).
Computes the upper tail of the F cdf with nu1
and nu2
degrees of freedom.
Must have: x
>= 0.
|
sampled value |
|
degrees of freedom for numerator |
|
degrees of freedom for denominator |
Returns : |
the upper-tail p-value |
gdouble oscats_rnd_t_p (gdouble x
,gdouble nu
);
If y_1 is distributed standard normal, and
y_2 is distributed Chi^2 with nu degrees of freedom,
w = y_1 / (y_2/nu) is distributed t(nu).
Computes the upper tail of the t cdf with nu
degrees of freedom.
|
sampled value |
|
degrees of freedom |
Returns : |
the upper-tail p-value |
void oscats_rnd_sample (const GPtrArray *population
,guint num
,GPtrArray *sample
,gboolean replace
);
Pointers are not ref'd when added to sample
.
Moreover, sample
should not have a GDestroyNotify.
|
objects from which to sample |
|
number of objects to sample |
|
return vector of sampled objects |
|
sample with replacement? |