Help for this page

Select Code to Download


  1. or download this
    use Statistics::R;
    sub     do_chi_squared_test_in_R {
    ...
            # returns [chi-squared-statistic, p-value]
            return [$chisquare, $pvalue]
    }
    
  2. or download this
            my $pvalue = -1;
            foreach (@{$Statistics::ChiSquare::chitable[$degrees_of_freedo
    +m]}) {
    ...
            }
            $pvalue = (@{$Statistics::ChiSquare::chilevels[$degrees_of_fre
    +edom]})[-1] unless $pvalue > -1;
            $pvalue /= 100; # 0-1 e.g. 5% -> 0.05
    
  3. or download this
    ./browser_uk_test_script.pl : number of cases with bias detected
    ./browser_uk_test_script.pl : standard-rand (using R) -> number of bia
    +s detected: 1 / 20
    ...
    ./browser_uk_test_script.pl : bad-rand (using Perl) -> number of bias 
    +detected: 16 / 20
            (pvalues=,0.01,0.01,0.01,0.01,0.05,0.01,0.01,0.01,0.05,0.01,0.
    +01,0.01,0.5,0.01,0.05,0.01,0.01,0.01,0.01,0.01)
    --------------------
    
  4. or download this
    ./browser_uk_test_script.pl : number of cases with bias detected
    ./browser_uk_test_script.pl : standard-rand (using R) -> number of bia
    +s detected: 0 / 20
    ...
    ./browser_uk_test_script.pl : MT-rand (using Perl) -> number of bias d
    +etected: 1 / 20
            (pvalues=,0.5,0.05,0.25,0.95,0.01,0.5,0.25,0.95,0.75,0.25,0.1,
    +0.5,0.1,0.75,0.25,0.25,0.1,0.1,0.5,0.25)
    --------------------
    
  5. or download this
    ./browser_uk_test_script.pl : number of cases with bias detected over 
    +20 tests
    ./browser_uk_test_script.pl : MT-rand (using R) -> number of bias dete
    +cted: 0 / 20
    ...
    ./browser_uk_test_script.pl : bad-rand (using Perl) -> number of bias 
    +detected: 12 / 20
            (pvalues=,0.01,0.5,0.01,0.05,0.01,0.1,0.05,0.01,0.25,0.01,0.01
    +,0.1,0.01,0.01,0.01,0.01,0.01,0.1,0.05,0.01)
    --------------------
    
  6. or download this
    do_chi_squared_test_in_R() : counts: 4317,4188,4099,4231,4258,4195,407
    +6,4330,4135,4143,4152,4191,3995,4176,4113,4088,4171,4132,4115,4154,41
    +65,4140,4246,4190 : x2=30.8192, pv=0.1273001
    do_chi_squared_test_in_perl() : counts: 4317,4188,4099,4231,4258,4195,
    +4076,4330,4135,4143,4152,4191,3995,4176,4113,4088,4171,4132,4115,4154
    +,4165,4140,4246,4190 : x2=30.8192, pv=0.1
    do_chi_squared_test_in_R() : counts: 4032,4106,4154,4136,4234,4065,416
    +6,4039,4279,4210,4031,4171,4279,4291,4132,4190,4281,4129,4179,4128,41
    +88,4172,4175,4233 : x2=33.10112, pv=0.07932075
    do_chi_squared_test_in_perl() : counts: 4032,4106,4154,4136,4234,4065,
    +4166,4039,4279,4210,4031,4171,4279,4291,4132,4190,4281,4129,4179,4128
    +,4188,4172,4175,4233 : x2=33.10112, pv=0.05</pre>
    
  7. or download this
    #!/usr/bin/env perl
    
    ...
            $pvalue /= 100; # 0-1 e.g. 5% -> 0.05
            return [$chisquare, $pvalue]
    }