Math::...Normal(3pm)

πŸ“¦
version 0.22 Β· 2 versions
  • 0.22 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.22 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Math::Random::OO::Normal β€” the perl manual page, bestie edition πŸ’–

okay so. you found yourself a Math::Random::OO::Normal(3pm) page, which means you're out here generating random numbers from the normal (Gaussian) distribution and honestly? iconic. this is a subclass of Math::Random::OO and it's giving bell curve realness. let's get into it πŸŽ€


✨ NAME ✨

Math::Random::OO::Normal β€” she generates random numbers from the normal (Gaussian) distribution. no cap. that's the whole job and she does it beautifully πŸ¦‹

🌸 VERSION 🌸

version 0.22 πŸ’…

🫢 SYNOPSIS 🫢

look at this gorgeous little snippet:

use Math::Random::OO::Normal;
push @prngs,
    Math::Random::OO::Normal->new(),     # mean 0, stdev 1
    Math::Random::OO::Normal->new(5),    # mean 5, stdev 1
    Math::Random::OO::Normal->new(1,3);  # mean 1, stdev 3
$_->seed(42) for @prngs;
print( $_->next() . "\n" ) for @prngs;

three lil generators, one seed, and then we print a number from each. it's giving "effortless". ✨


🧚 DESCRIPTION 🧚

so here's the tea, bestie. this subclass of Math::Random::OO generates random reals from the normal probability distribution β€” you might also know her as the Gaussian distribution or the bell-curve distribution. same queen, different names πŸ‘‘

the module generates random normals from the inverse of the cumulative normal distribution, using an approximation algorithm developed by Peter J. Acklam and released into the public domain. this algorithm claims a relative error of less than 1.15e-9 over the entire region. that's precise. that's discipline. that's main character energy fr fr πŸ’…

want the details and discussion? it lives at http://home.online.no/~pjacklam/notes/invnorm/ 🌈


πŸ’œ METHODS πŸ’œ

🌟 "new" 🌟

$prng1 = Math::Random::OO::Normal->new();
$prng2 = Math::Random::OO::Normal->new($mean);
$prng3 = Math::Random::OO::Normal->new($mean,$stdev);

new takes up to two optional parameters and returns a new Math::Random::OO::Normal object. let's break it down by vibe check:

  • no parameters β†’ the object generates random numbers from the standard normal distribution (mean zero, standard deviation one). the classic. the blueprint.
  • one parameter β†’ the object generates random numbers with mean equal to the parameter and a standard deviation of one.
  • two parameters β†’ the object generates random numbers with mean equal to the first parameter and standard deviation equal to the second parameter.
one lil note: standard deviation should be positive, but this module takes the absolute value of the parameter just in case. she's forgiving like that 🫢

🌟 "seed" 🌟

$rv = $prng->seed( @seeds );

this method seeds the random number generator. at the moment, only the first seed value matters. it should be a positive integer. (so like, don't get cute with it, bestie πŸ’€)

🌟 "next" 🌟

$rnd = $prng->next();

this method returns the next random number from the random number generator. it does not take any parameters. no arguments, no drama, just vibes and numbers πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

David Golden <dagolden@cpan.org> β€” thank you king πŸ™‡β™€οΈ

This software is Copyright (c) 2013 by David Golden.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004
free software AND licensed properly? we love a responsible icon πŸ’–

and that's the whole page, bestie πŸŽ€ you came here for a bell curve and you left with the whole distribution. slay. periodt. πŸ’…

perl v5.36.0 Β· 2022-12-12 Β· Math::...Normal(3pm) β€” mwah, thanks for reading, ily, go generate some random numbers πŸ’œβœ¨