Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
# MZT random number generator # # distribution: uniform # use r_univ() to get number from 0.0 to 1.0 package r_univ; use strict; use warnings; use Exporter; our @ISA=qw/Exporter/; our @EXPORT=qw/r_univ/; my @uu; my ($cc,$cd,$cm)=(362436.0/16777216.0, 7654321.0/16777216.0, 16777213.0/16777216.0); my ($ip,$jp)=(97,33); sub r_univ_init_rep($$$$){ my ($wi,$wj,$wk,$wl)=@_; my ($m,$t); foreach my $ii (0..96){ my ($s,$t)=(0,0.5); foreach my $jj (1..24){ $m=((($wi*$wj)%179)*$wk)%179; $wi=$wj; $wj=$wk; $wk=$m; $wl=(53*$wl+1)%169; $s+=$t if (($wl*$m)&63)>0x1f; $t*=0.5; $uu[$ii]=$s; } } } sub r_univ_init(){ srand(time()); my ($a,$b,$c,$d); do{ $a=1+rand()*178; $b=1+rand()*178; $c=1+rand()*178; $d=rand()*167; }while($a+$b+$c <= 3); r_univ_init_rep($a,$b,$c,$d); } sub r_univ(){ my $aux; $aux=$uu[$ip-1]-$uu[$jp-1]; ++$aux if($aux<0.0); $uu[$ip-1]=$aux; --$ip; $ip=97 unless $ip; --$jp; $jp=97 unless $jp; $cc-=$cd; $cc+=$cm if $cc<0.0; $aux-=$cc; ++$aux if $aux<0.0; return $aux; } r_univ_init(); 1;

In reply to MZT random number generator by js29a

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found