random.cpp File Reference


Detailed Description

Simple random number generator.

Definition in file random.cpp.

#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include "random.hpp"

Include dependency graph for random.cpp:

Include dependency graph

Go to the source code of this file.

Defines

#define Mbig   1000000000.
#define Mseed   161803398.
#define imod(x, y)   ((x)-((x)/(y))*(y))

Functions

double Rand (long seed)
 Generate random numbers uniformly distributed from 0 to 1.
double RandNorm (double sigma)
 Generate normally distributed random numbers, zero mean and sqrt of variance sigma.
int ARand (int low, int hi)
 Return random integers between low and hi.
double ARand (double low, double hi)
 Return random doubles between low and hi.
double RandomWalk (double dt, double sigma, double xlast)
 Generate a random walk sequence, given sqrt variance sigma, time step dt and previous point xlast.
double RandExpCor (double dt, double sigma, double T, double xlast)
 Generate exponentially correlated random numbers, given sqrt variance sigma, time step dt, time constant T, and previous point xlast.


Define Documentation

#define imod x,
 )     ((x)-((x)/(y))*(y))
 

Referenced by Rand().

#define Mbig   1000000000.
 

Referenced by Rand().

#define Mseed   161803398.
 

Referenced by Rand().


Function Documentation

double ARand double  low,
double  hi
 

Return random doubles between low and hi.

Seed the generator by calling Rand(seed) before this call.

Definition at line 135 of file random.cpp.

References Rand().

int ARand int  low,
int  hi
 

Return random integers between low and hi.

Seed the generator by calling Rand(seed) before this call.

Definition at line 123 of file random.cpp.

double Rand long  seed  ) 
 

Generate random numbers uniformly distributed from 0 to 1.

Definition at line 43 of file random.cpp.

References imod, Mbig, and Mseed.

Referenced by ARand(), and RandNorm().

double RandExpCor double  dt,
double  sigma,
double  T,
double  xlast
 

Generate exponentially correlated random numbers, given sqrt variance sigma, time step dt, time constant T, and previous point xlast.

Definition at line 154 of file random.cpp.

References gpstk::exp(), and RandNorm().

double RandNorm double  sigma  ) 
 

Generate normally distributed random numbers, zero mean and sqrt of variance sigma.

Uses Box-Muller and Rand().

Definition at line 89 of file random.cpp.

References log, Rand(), and gpstk::sqrt().

Referenced by RandExpCor(), and RandomWalk().

double RandomWalk double  dt,
double  sigma,
double  xlast
 

Generate a random walk sequence, given sqrt variance sigma, time step dt and previous point xlast.

Definition at line 146 of file random.cpp.

References RandNorm().


Generated on Tue Feb 7 03:31:18 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1