blog.x-e.ro / math: page 1 of 6

another as3 range seeded randomizer

as3 :: random number in flash

just another take on a classic piece of code. the pseudo-random number generator. this one is almost the same, just a slightly diffrent algorithm.

private function randomizer(low:Number, high:Number):Number {
	var num:Number = high-low;
	return (Math.random()*num)+low;
}

then use it...

var x:Number = randomizer(5, 50);

i <3 randomization

Read: another as3 range seeded randomizer »

the lorenz attractor

demos :: with papervision3D

papervision3D lorenz attractor

we were discussing recursive algorithms and chaos theory at work yesterday. when one of the chemistry professors brought up the lorenz attractor. he was trying to draw one on the white board for about 10 minutes until i decided it would be easier to draw in flash, lol!

after a quick conversation w/ andy zupko about the new Line3D object, and my new CanvasView3D component for papervision, i made a sweet lorenz attractor! 

the algorithm is super simple:

x1 = x0 + h * a * (y0 - x0);
y1 = y0 + h * (x0 * (b - z0) - y0);
z1 = z0 + h * (x0 * y0 - c * z0); 

Read: the lorenz attractor »

asp.net random number generator

c-sharp :: the central randomizer

here is my asp.net randomizer class based on the c R250/512 shift-register sequence random number generator, by kirkpatrick and stoll and published (j. computational physics, vol 40, pp. 517-526) with an added a pseudo-random class redefinition and buffer overflow protection.

example usage:

randomizer x = new randomizer();
int num = x.random();

Read: asp.net random number generator »

random page perl script

perl :: CGI randomization

place this code in a file called index.cgi, chmod it to 775, and place it in a directory of html files. this script will pick one of the files in the specified directory at random, and print it to the screen. refresh the page for a new random one.

#!/usr/bin/perl
print "Content-type: text/html\n\n";
 
#print "<pre>";
$basep = "/wwwroot/path2/randomdir";
 
srand(time ^ $$);
#print "got random time...\n";
 
@files = `ls $basep/*.html`;
#print "got file list...\n";
#foreach (@files) { print "-----$_\n";}
 
$file = rand(@files);
#print "got random file...$phrase\n";
 
$nupath = "$files[$file]";
#print "got new path...$nupath\n";
 
open(LOG, $nupath) or die "$!\n"; 
while () 
{
  print $_;
}
close (LOG);
#print "</pre>";

exit;

Read: random page perl script »

loading...

loading...