Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

zigrandom.cc File Reference


Detailed Description

========================================================================== This code is Copyright (C) 2005, Jurgen A. Doornik. Permission to use this code for non-commercial purposes is hereby given, provided proper reference is made to: Doornik, J.A. (2005), "An Improved Ziggurat Method to Generate Normal Random Samples", mimeo, Nuffield College, University of Oxford, and www.doornik.com/research. or the published version when available. This reference is still required when using modified versions of the code. This notice should be maintained in modified versions of the code. No warranty is given regarding the correctness of this code. ==========================================================================

Author:
Jurgen A. Doornik (Creator)
Author
ejt
Name
tekkotsu-4_0
Revision
1.2
State
Exp
Date
2007/01/30 23:17:12

Definition in file zigrandom.cc.

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "zigrandom.h"

Include dependency graph for zigrandom.cc:

Go to the source code of this file.

Defines

#define MWC_R   256
#define MWC_A   LIT_UINT64(809430660)
#define MWC_AI   809430660
#define MWC_C   362436
#define POLARBLOCK(u1, u2, d)
#define FPOLARBLOCK(u1, u2, d)

Functions

void GetInitialSeeds (unsigned int auiSeed[], int cSeed, unsigned int uiSeed, unsigned int uiMin)
void RanSetSeed_MWC8222 (int *piSeed, int cSeed)
unsigned int IRan_MWC8222 (void)
double DRan_MWC8222 (void)
void VecIRan_MWC8222 (unsigned int *auiRan, int cRan)
void VecDRan_MWC8222 (double *adRan, int cRan)
double DRanU (void)
unsigned int IRanU (void)
void RanVecIntU (unsigned int *auiRan, int cRan)
void RanVecU (double *adRan, int cRan)
void RanSetSeed (int *piSeed, int cSeed)
void RanSetRan (const char *sRan)
static unsigned int IRanUfromDRanU (void)
static double DRanUfromIRanU (void)
void RanSetRanExt (DRANFUN DRanFun, IRANFUN IRanFun, IVECRANFUN IVecRanFun, DVECRANFUN DVecRanFun, RANSETSEEDFUN RanSetSeedFun)
double DRanNormalPolar (void)
double FRanNormalPolar (void)
static double dProbN (double x, int fUpper)
double DProbNormal (double x)
double DRanQuanNormal (void)
double FRanQuanNormal (void)

Variables

static unsigned int s_uiStateMWC = MWC_R - 1
static unsigned int s_uiCarryMWC = MWC_C
static unsigned int s_auiStateMWC [MWC_R]
static int s_cNormalInStore = 0
static DRANFUN s_fnDRanu = DRan_MWC8222
static IRANFUN s_fnIRanu = IRan_MWC8222
static IVECRANFUN s_fnVecIRanu = VecIRan_MWC8222
static DVECRANFUN s_fnVecDRanu = VecDRan_MWC8222
static RANSETSEEDFUN s_fnRanSetSeed = RanSetSeed_MWC8222
static double s_dNormalInStore
static float s_fNormalInStore


Define Documentation

#define FPOLARBLOCK ( u1,
u2,
 ) 

Value:

do                                        \
  {   u1 = (float)((*s_fnDRanu)());  u1 = 2 * u1 - 1;\
    u2 = (float)((*s_fnDRanu)());  u2 = 2 * u2 - 1;\
    d = u1 * u1 + u2 * u2;                \
  } while (d >= 1);                         \
  d = sqrt( (-2.0 / d) * log(d) );          \
  u1 *= d;  u2 *= d

Definition at line 242 of file zigrandom.cc.

#define MWC_A   LIT_UINT64(809430660)

Definition at line 56 of file zigrandom.cc.

Referenced by DRan_MWC8222(), IRan_MWC8222(), VecDRan_MWC8222(), and VecIRan_MWC8222().

#define MWC_AI   809430660

Definition at line 57 of file zigrandom.cc.

#define MWC_C   362436

Definition at line 58 of file zigrandom.cc.

Referenced by RanSetSeed_MWC8222().

#define MWC_R   256

#define POLARBLOCK ( u1,
u2,
 ) 

Value:

do                                        \
  {   u1 = (*s_fnDRanu)();  u1 = 2 * u1 - 1;\
    u2 = (*s_fnDRanu)();  u2 = 2 * u2 - 1;\
    d = u1 * u1 + u2 * u2;                \
  } while (d >= 1);                         \
  d = sqrt( (-2.0 / d) * log(d) );          \
  u1 *= d;  u2 *= d

Definition at line 216 of file zigrandom.cc.

Referenced by DRanNormalPolar(), and FRanNormalPolar().


Function Documentation

static double dProbN ( double  x,
int  fUpper 
) [static]

Definition at line 269 of file zigrandom.cc.

Referenced by DProbNormal().

double DProbNormal ( double  x  ) 

double DRan_MWC8222 ( void   ) 

Definition at line 91 of file zigrandom.cc.

Referenced by RanSetRan().

double DRanNormalPolar ( void   ) 

Definition at line 227 of file zigrandom.cc.

Referenced by DRanQuanNormal().

double DRanQuanNormal ( void   ) 

Definition at line 306 of file zigrandom.cc.

double DRanU ( void   ) 

Definition at line 144 of file zigrandom.cc.

Referenced by DRanNormalTail(), DRanNormalZig(), and DRanNormalZigVec().

static double DRanUfromIRanU ( void   )  [static]

Definition at line 199 of file zigrandom.cc.

Referenced by RanSetRanExt().

double FRanNormalPolar ( void   ) 

Definition at line 252 of file zigrandom.cc.

Referenced by FRanQuanNormal().

double FRanQuanNormal ( void   ) 

Definition at line 310 of file zigrandom.cc.

void GetInitialSeeds ( unsigned int  auiSeed[],
int  cSeed,
unsigned int  uiSeed,
unsigned int  uiMin 
)

Definition at line 36 of file zigrandom.cc.

Referenced by RanSetSeed_MWC8222().

unsigned int IRan_MWC8222 ( void   ) 

Definition at line 81 of file zigrandom.cc.

Referenced by RanSetRan().

unsigned int IRanU ( void   ) 

Definition at line 148 of file zigrandom.cc.

Referenced by DRanNormalZig(), DRanNormalZig32(), and DRanNormalZig32Vec().

static unsigned int IRanUfromDRanU ( void   )  [static]

Definition at line 195 of file zigrandom.cc.

Referenced by RanSetRanExt().

void RanSetRan ( const char *  sRan  ) 

Definition at line 177 of file zigrandom.cc.

void RanSetRanExt ( DRANFUN  DRanFun,
IRANFUN  IRanFun,
IVECRANFUN  IVecRanFun,
DVECRANFUN  DVecRanFun,
RANSETSEEDFUN  RanSetSeedFun 
)

Definition at line 203 of file zigrandom.cc.

void RanSetSeed ( int *  piSeed,
int  cSeed 
)

Definition at line 172 of file zigrandom.cc.

Referenced by RanNormalSetSeedZig(), and RanNormalSetSeedZig32().

void RanSetSeed_MWC8222 ( int *  piSeed,
int  cSeed 
)

Definition at line 63 of file zigrandom.cc.

Referenced by RanSetRan().

void RanVecIntU ( unsigned int *  auiRan,
int  cRan 
)

Definition at line 152 of file zigrandom.cc.

Referenced by DRanNormalZig32Vec(), and DRanNormalZigVec().

void RanVecU ( double *  adRan,
int  cRan 
)

Definition at line 156 of file zigrandom.cc.

Referenced by DRanNormalZigVec().

void VecDRan_MWC8222 ( double *  adRan,
int  cRan 
)

Definition at line 116 of file zigrandom.cc.

void VecIRan_MWC8222 ( unsigned int *  auiRan,
int  cRan 
)

Definition at line 101 of file zigrandom.cc.

Referenced by RanSetRan().


Variable Documentation

unsigned int s_auiStateMWC[MWC_R] [static]

Definition at line 61 of file zigrandom.cc.

int s_cNormalInStore = 0 [static]

Definition at line 136 of file zigrandom.cc.

double s_dNormalInStore [static]

Definition at line 225 of file zigrandom.cc.

DRANFUN s_fnDRanu = DRan_MWC8222 [static]

Definition at line 138 of file zigrandom.cc.

IRANFUN s_fnIRanu = IRan_MWC8222 [static]

Definition at line 139 of file zigrandom.cc.

float s_fNormalInStore [static]

Definition at line 251 of file zigrandom.cc.

RANSETSEEDFUN s_fnRanSetSeed = RanSetSeed_MWC8222 [static]

Definition at line 142 of file zigrandom.cc.

DVECRANFUN s_fnVecDRanu = VecDRan_MWC8222 [static]

Definition at line 141 of file zigrandom.cc.

IVECRANFUN s_fnVecIRanu = VecIRan_MWC8222 [static]

Definition at line 140 of file zigrandom.cc.

unsigned int s_uiCarryMWC = MWC_C [static]

Definition at line 60 of file zigrandom.cc.

unsigned int s_uiStateMWC = MWC_R - 1 [static]

Definition at line 59 of file zigrandom.cc.


Tekkotsu v4.0
Generated Thu Nov 22 00:58:08 2007 by Doxygen 1.5.4