librand.pl
author A.M. Thurnherr <athurnherr@yahoo.com>
Wed, 06 Jan 2016 22:09:29 +0000
changeset 24 2fd9d279e105
child 25 47b4a3600f5a
permissions -rw-r--r--
transport version

#======================================================================
#                    L I B R A N D . P L 
#                    doc: Thu Nov 19 14:27:19 2015
#                    dlm: Thu Nov 19 14:57:53 2015
#                    (c) 2015 A.M. Thurnherr
#                    uE-Info: 22 52 NIL 0 0 72 2 2 4 NIL ofnI
#======================================================================

sub gauss_rand($$)
{
	my($mu,$sigma) = &antsFunUsage(2,'ff','mu, sigma',@_);
}

#----------------------------------------------------------------------------------------------------
# From info found at [http://www.mathworks.com/matlabcentral/newsreader/view_thread/301276]
#
# verified with:
#   plot '<Cat -Lrand -f =1,1,1e5 -F r=pwrlaw_rand(-2) | Hist -s 100 r | Cat -S $2>2' lt 3,x**-2*1e7
#	plot '<Cat -Lrand -f =1,1,1e5 -F r=pwrlaw_rand(-3) | Hist r',x**-3*7e3
#	plot '<Cat -Lrand -f =1,1,1e5 -F r=pwrlaw_rand(0) | Hist -s 0.01 r'
#	plot '<Cat -Lrand -f =1,1,1e5 -F r=pwrlaw_rand(1) | Hist -s 0.01 r'
#	plot '<Cat -Lrand -f =1,1,1e5 -F r=pwrlaw_rand(2) | Hist -s 0.01 r'
#----------------------------------------------------------------------------------------------------

sub pwrlaw_rand($)		
{
	my($p) = &antsFunUsage(1,'f','exponent',@_);
	return rand() ** (1/($p+1));
}

1;