Math::...otstrap(3pm)
β¨ Math::...otstrap π
okay bestie, welcome to Math::Random::OO::Bootstrap β it's a Perl module, it lives in the User Contributed Perl Documentation section (man page Math::...otstrap(3pm), iykyk), and it does exactly one thing but does it flawlessly: it generates random numbers by bootstrap resampling from a non-parametric distribution. no cap. π
πΈ NAME πΈ
Math::Random::OO::Bootstrap β generate random numbers with bootstrap resampling from a non-parametric distribution. literally that's the whole vibe. π
π¦ VERSION π¦
version 0.22 β¨
π SYNOPSIS π
use Math::Random::OO::Bootstrap;
@sample = qw( 2 3 3 4 4 5 5 6 6 7 );
$prng = Math::Random::OO::Bootstrap->new(@sample);
$prng->seed(42);
$prng->next() # draws randomly from the sample
see how cute that is?? you hand it a lil pile of observations, you seed it, and it just hands you back random picks from the pile. main character energy fr fr. π
π DESCRIPTION π
so this is a subclass of Math::Random::OO, and what it does is generate random numbers with bootstrap resampling β that's resampling with replacement, bestie, meaning you can pull the same value over and over β from a given set of observations.
and the way each item in the sample array gets drawn? equal probability. every single one. no favourites, no rigging, no drama. π
π METHODS π
π new
$prng = Math::Random::OO::Bootstrap->new(@sample);
$prng = Math::Random::OO::Bootstrap->new(\@sample);
new takes either a list or a reference to an array holding a set of observations, and returns you a brand new Math::Random::OO::Bootstrap object. π«Ά
and here's the thoughtful part: if you hand it a reference, the object makes an internal copy of the array β so if you go and mutate your original array afterwards, nothing chaotic happens. it's giving "I made a backup, you're welcome." π
β οΈ important!! if the sample you want is an array of array references, you gotta wrap that list in an anonymous array reference, or it gets ambiguous and things go wrong. listen:
@sample = ( [ 1, 2, 3], [2, 3, 4] );
# Correct way
$prng = Math::Random::OO::Bootstrap->new( [ @sample ] );
# Incorrect -- will only use [1, 2, 3] as the desired sample
$prng = Math::Random::OO::Bootstrap->new( @sample );
see that?? the "incorrect" one only uses [1, 2, 3] as the desired sample. so do the correct one. do it. π
and also: calling new with no arguments is an error. don't do that. π
π seed
$rv = $prng->seed( @seeds );
this method seeds the random number generator. π±
at the moment, only the first seed value matters β the rest are just kinda there, vibing. and it should be a positive integer. that's it, that's the tea. π
π next
$rnd = $prng->next();
this method returns the next random number from the random number generator by resampling with replacement from the provided data. π²
it does not take any parameters. zero. none. it just shows up and delivers. iconic behaviour honestly. β¨
π AUTHOR π
David Golden <dagolden@cpan.org> π
π 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
okay that's the whole page bestie!! π¦ this was perl v5.36.0, dated 2022-12-12, from the Math::...otstrap(3pm) man page β mwah, go forth and resample responsibly, ily, periodt. πβ¨π
π¦ 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