Skip to content
Snippets Groups Projects
Commit 41173248 authored by zhang's avatar zhang
Browse files

15/03/2011

1) Add comments
parent 2f2c5497
No related branches found
No related tags found
No related merge requests found
......@@ -39,15 +39,68 @@ void iniranf(const long i)
rseed0 = i; rseed = i;
}
#define k 19
#define c 656329L
#define m 100000001
/****************************************************************************/
/* void newseed(void)
Purpose: define a new seed
input:
none
output:
none
return:
none
global variables:
rseed0
rseed
k, c, m
specific functions:
none
comments
none
****************************************************************************/
void newseed(void)
{
rseed0 = (k*rseed0+c) % m; rseed = (rseed0+54321) % m;
}
/****************************************************************************/
/* double ranf(void)
Purpose: Generate a random number with rectangular distribution/uniform
distribution between the value [0, m]
input:
none
output:
none
return:
random number of type double
global variables:
rseed0
rseed
k, c, m
specific functions:
none
comments
none
****************************************************************************/
double ranf(void)
{
/* Generate random number with rectangular distribution */
......@@ -58,7 +111,30 @@ double ranf(void)
#undef c
#undef m
/****************************************************************************/
/* void setrancut(double cut)
Purpose: Set a cut for normal distribution
input:
cut : number of sigma for cutting the distribution
output:
none
return:
none
global variables:
normcut_
specific functions:
none
comments
none
****************************************************************************/
void setrancut(const double cut)
{
......@@ -68,7 +144,34 @@ void setrancut(const double cut)
normcut_ = cut;
}
/****************************************************************************/
/* double normranf(void)
Purpose:
Generate random numbers with Gaussian/normal distribution (m=0, sigma=1)
and cut normcut_
input:
none
output:
none
return:
random number
global variables:
normcut_
maxiter
specific functions:
ranf
comments
none
****************************************************************************/
/* maximum number of iteration to generate the random number */
#define maxiter 100
double normranf(void)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment