#!/usr/bin/perl -w
use strict;
use Math::Random;
use Statistics::Descriptive;

my $N = 1000000;
my $mean = 0;
my $std = 2;
my @rndN = random_normal($N, $mean, $std);
my @rndN2 = random_uniform($N);

my $stat = Statistics::Descriptive::Full->new();
my $stat2 = Statistics::Descriptive::Full->new();
$stat->add_data(@rndN);
$stat2->add_data(@rndN2);

print 
    "Some statistical properties of $N normally distributed random numbers\n",
    "with mean $mean and standard deviation $std:\n\n",
    "           Mean: ", $stat->mean(), "\n",
    "       Variance: ", $stat->variance(), "\n",
    "        Std dev: ", $stat->standard_deviation(), "\n",
    "            Min: ", $stat->min(), "\n",
    "            Max: ", $stat->max(), "\n",
    "25th Percentile: ", $stat->percentile(25), "\n",
    "95th Percentile: ", $stat->percentile(95), "\n";

print 
    "Some statistical properties of $N flatly distributed random numbers\n",
    "           Mean: ", $stat2->mean(), "\n",
    "       Variance: ", $stat2->variance(), "\n",
    "        Std dev: ", $stat2->standard_deviation(), "\n",
    "            Min: ", $stat2->min(), "\n",
    "            Max: ", $stat2->max(), "\n",
    "25th Percentile: ", $stat2->percentile(25), "\n",
    "95th Percentile: ", $stat2->percentile(95), "\n";
