Math::...Uniform(3pm)
π Math::Random::OO::Uniform β the manual, but make it cute π
okay so bestie, you're reading a User Contributed Perl Documentation page, and the module in question is Math::Random::OO::Uniform. It lives in the Math::Random::OO family and it does exactly one thing and it does it flawlessly: it hands you random reals from the uniform probability distribution. That's it. That's the girl. π
β¨ VERSION β¨
version 0.22 β the era we're living in, no cap.
πΈ SYNOPSIS πΈ
Here's the whole vibe in one code block, mwah:
use Math::Random::OO::Uniform;
push @prngs,
Math::Random::OO::Uniform->new(), # range [0,1)
Math::Random::OO::Uniform->new(5), # range [0,5)
Math::Random::OO::Uniform->new(-1,1); # range [-1,1)
$_->seed(42) for @prngs;
print( $_->next() . "\n" ) for @prngs;
Look at her. Three generators, three different ranges, all seeded with 42, all printing their little numbers. iconic behaviour honestly. π
π¦ DESCRIPTION π¦
So this is a subclass of Math::Random::OO, and it generates random reals from a uniform probability distribution. That means every number in the range has the same chance as every other number. Fair. Balanced. Demure, even. π§
π METHODS π
π new
$prng1 = Math::Random::OO::Uniform->new();
$prng2 = Math::Random::OO::Uniform->new($high);
$prng3 = Math::Random::OO::Uniform->new($low,$high);
new takes up to two optional parameters and returns a brand new Math::Random::OO::Uniform object. Let's break it down because the three moods are all different:
- No parameters β the object generates random numbers in the range of zero (inclusive) to one (exclusive). So
[0,1), basically. - One parameter β the object generates random numbers from zero (inclusive) to the value of the parameter (exclusive).
β οΈ Important lore: the object does this with multiplication, so if the parameter is negative, the function will return negative numbers. The original docs say this is a feature or bug, depending on your point of view β and honestly? That's the most real thing in this whole manpage. π
- Two parameters β the object generates random numbers from the first parameter (inclusive) to the second parameter (exclusive). And a little secret: as long as you have two parameters,
newwill put them in the right order. So she's got your back. π«Ά
π seed
$rv = $prng->seed( @seeds );
This method seeds the random number generator. Currently, only the first seed value matters β the rest are just there, chilling. It should be a positive integer. β¨
π 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> β the mastermind, the moment, the main character. π
πΈ COPYRIGHT AND LICENSE πΈ
This software is Copyright (c) 2013 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
Slay, legally speaking. βοΈβ¨
okay bestie that's the whole page, you ate it, go generate some uniform random numbers and be free π¦π
this was perl v5.36.0, dated 2022-12-12, from Math::...Uniform(3pm) β bye babes, ily, use protection (seed your PRNG) π
π
π¦ where this page comes from
- debian bookworm: libmath-random-oo-perl 0.22-3 Β· Apache-2.0
- debian trixie: libmath-random-oo-perl 0.22-3 Β· Apache-2.0
- ubuntu noble: libmath-random-oo-perl 0.22-3 Β· Apache-2.0
- ubuntu resolute: libmath-random-oo-perl 0.22-3 Β· Apache-2.0
- ubuntu stonking: libmath-random-oo-perl 0.22-3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms