Difference between revisions of "RandomNumberGeneratorExponentialPareto"

From Nsnam
Jump to: navigation, search
(Methodology)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Confused Random Number Generator ==
 
== Confused Random Number Generator ==
  
This test is an illustration of what might happen if a random number generator produced an incorrect distribution.  At a glance, the Pareto and exponential distributions are similar.  In this test, we intentionally generate a Pareto distribution and compare it to an exponential distribution.
+
This test is an illustration of what might happen if a random number generator produced an incorrect distribution.  The Pareto distribution takes a shape parameter.  In this test, we intentionally generate a Pareto distribution with a slightly different shape parameter (alpha = 1.1) and compare it to a Pareto distribution with alpha = 1.0.
  
Our goal is to show that a random number generator that generates a Pareto distribution fails a chi square test for an exponential distribution.
+
Our goal is to show that a random number generator that generates an incorrectly shaped Pareto distribution fails the chi square test.
  
 
=== Methodology ===
 
=== Methodology ===
  
We apply a chi square test of goodness of fit to evaluate the function.  We create a histogram with 50 bins uniformly distributed across the range [1, 10) and expand the upper boundary bin to extend the range to +infinity.  We generate 1 000 000 random numbers which we assign to appropriate bins in the histogram.
+
We apply a chi square test of goodness of fit to evaluate the function.  We create a histogram with 50 bins uniformly distributed across the range [1, 10) and expand the upper boundary bin to extend the range to +infinity.  We generate 1 000 000 random numbers using the '''ParetoVariable''' with shape parameter = 1.1 which we assign to appropriate bins in the histogram.
  
Since the expected value is provided for us (we do not calculate it from the data) the degrees of freedom in the chi square test is 50.  Using this value, we calculate a maximum chi squared statistic corresponding to the 0.05 significance level (using the GNU Scientific Library gsl_cdf_chisq_Qinv function) as 67.5048.  Ten runs of the test for goodness of fit results in an average chi square statistic of 828766.
+
Since the expected value is provided for us (we do not calculate it from the data) the degrees of freedom in the chi square test is 50.  Using this value, we calculate a maximum chi squared statistic corresponding to the 0.05 significance level (using the GNU Scientific Library gsl_cdf_chisq_Qinv function) as 67.5048.  We calculate the expected values using a shape parameter of alpha = 1.0.  Ten runs of the test for goodness of fit results in an average chi square statistic of 4695.05.
  
Since this massively greater than the rejection value of 67.5048 we can state that the chi square statistic we measured is inconistent with statistical fluctuations and that the ns-3 Pareto random number generator does, in fact, '''not''' generate random numbers distributed according to the exponential distribution.
+
Since this massively greater than the rejection value of 67.5048 we can state that the chi square statistic we measured is inconistent with statistical fluctuations and that the ns-3 Pareto random number, when given a shape parameter of 1.1 generator does, in fact, '''not''' generate random numbers distributed according to the Pareto distribution with shape parameter 1.0.
  
 
=== Data ===
 
=== Data ===
Line 19: Line 19:
 
Note that the actual values correspond to a Pareto distribution and the expected values correspond to an exponential distribution.
 
Note that the actual values correspond to a Pareto distribution and the expected values correspond to an exponential distribution.
  
[[Image:Rng-exppar.png]]
+
[[Image:Rng-wrongpareto.png]]
  
 
----
 
----
 
[[User:Craigdo|Craigdo]] 20:48, 17 April 2009 (UTC)
 
[[User:Craigdo|Craigdo]] 20:48, 17 April 2009 (UTC)

Latest revision as of 23:49, 17 April 2009

Confused Random Number Generator

This test is an illustration of what might happen if a random number generator produced an incorrect distribution. The Pareto distribution takes a shape parameter. In this test, we intentionally generate a Pareto distribution with a slightly different shape parameter (alpha = 1.1) and compare it to a Pareto distribution with alpha = 1.0.

Our goal is to show that a random number generator that generates an incorrectly shaped Pareto distribution fails the chi square test.

Methodology

We apply a chi square test of goodness of fit to evaluate the function. We create a histogram with 50 bins uniformly distributed across the range [1, 10) and expand the upper boundary bin to extend the range to +infinity. We generate 1 000 000 random numbers using the ParetoVariable with shape parameter = 1.1 which we assign to appropriate bins in the histogram.

Since the expected value is provided for us (we do not calculate it from the data) the degrees of freedom in the chi square test is 50. Using this value, we calculate a maximum chi squared statistic corresponding to the 0.05 significance level (using the GNU Scientific Library gsl_cdf_chisq_Qinv function) as 67.5048. We calculate the expected values using a shape parameter of alpha = 1.0. Ten runs of the test for goodness of fit results in an average chi square statistic of 4695.05.

Since this massively greater than the rejection value of 67.5048 we can state that the chi square statistic we measured is inconistent with statistical fluctuations and that the ns-3 Pareto random number, when given a shape parameter of 1.1 generator does, in fact, not generate random numbers distributed according to the Pareto distribution with shape parameter 1.0.

Data

The following is a histogram of the random numbers generated in one run of the test. Expected values are calulated based on the area of the cumulative distribution function corresponding to the histogram bin. This expected value is calculated using the GNU Scientific Library gsl_cdf_exponential_P function.

Note that the actual values correspond to a Pareto distribution and the expected values correspond to an exponential distribution.

Rng-wrongpareto.png


Craigdo 20:48, 17 April 2009 (UTC)