Exponential Distribution Checker
A Program that Runs Experiments on Generating Random Numbers with an Exponential Distribution
 All Files Functions Variables Macros Pages
Functions | Variables
main.cpp File Reference

Main. More...

#include <stdio.h>
#include <stdlib.h>
#include "Random.h"
#include "defines.h"

Functions

void ResetDistribution ()
 Reset the measured distribution.
 
void RunExperiment (float omega, int n)
 Run an experiment.
 
void SaveDistribution (FILE *filehandle)
 Save.
 
void CheckDistribution ()
 Check the frequency distribution and report to console.
 
int main (int argc, char *argv[])
 Main.
 

Variables

const int GRANULARITY = 100
 Granularity at which to measure the distribution.
 
const int REPEATS = 10000000
 Number of times we repeat the experiment.
 
int g_nDistribution [GRANULARITY]
 Experimental frequency distribution.
 
int g_nMissedSmall
 How many experiments were too small (should be 0).
 
int g_nMissedLarge
 How many experiments were too large (should be 0).
 
float g_fMin
 Smallest value found (ideally close to 0).
 
float g_fMax
 Largest value found (ideally close to 1).
 

Function Documentation

void CheckDistribution ( )

Check the frequency distribution and report interesting things to console.

int main ( int  argc,
char *  argv[] 
)

Prompts the user for a random number seed and a tail multiplier, then measures statistics, and saves information about the distribution to a file.

Parameters
argcArgument count
argvArguments.
Returns
0 for success, 1 for failure.
void ResetDistribution ( )

Reset all the statistics to zero. Call this before you start measuring.

void RunExperiment ( float  omega,
int  n 
)

Run an experiment to measure the frequency distribution.

Parameters
omegaThe tail multiplier, which controls how low the tails of the distribution can be.
nNumber of times to repeat the experiment.
void SaveDistribution ( FILE *  filehandle)

Save the frequency distribution.

Parameters
filehandleFile handle opened for writing.