Title: | A Pseudo-Random Number Generator |
---|---|
Description: | Provides functions for generating pseudo-random numbers that follow a uniform distribution [0,1]. Randomness tests were conducted using the National Institute of Standards and Technology test suite<https://csrc.nist.gov/pubs/sp/800/22/r1/upd1/final>, along with additional tests. The sequence generated depends on the initial values and parameters. The package includes a linear congruence map as the decision map and three chaotic maps to generate the pseudo-random sequence, which follow a uniform distribution. Other distributions can be generated from the uniform distribution using the Inversion Principle Method and BOX-Muller transformation. Small perturbations in seed values result in entirely different sequences of numbers due to the sensitive nature of the maps being used. The chaotic nature of the maps helps achieve randomness in the generator. Additionally, the generator is capable of producing random bits. |
Authors: | Sajad Ahmad Mir [aut, cre] |
Maintainer: | Sajad Ahmad Mir <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.2.1.3 |
Built: | 2025-03-08 04:15:38 UTC |
Source: | https://github.com/meer-1/prng |
this is a chaotic map with the sensitive for the parameter value greater than 0.5
baker_map(x0, a)
baker_map(x0, a)
x0 |
seed value |
a |
parameter of the map range is greater than 0.5 |
for 0<=x=<1/2 the map returns 2ax for 1/2<=x<=1 the map returns a(2x-1)mod1
baker_map(0.3,0.56)
baker_map(0.3,0.56)
the map is a member of the family of the maps f(x)=(ax+b) mod(n)
linear_con(x0)
linear_con(x0)
x0 |
seed value |
the map gives an integer ax+b mod(n)
linear_con(5)
linear_con(5)
This is the most used chaotic map . The map is sensitive for the value of the parameter greater than 3.568
logistic_map(x0, a)
logistic_map(x0, a)
x0 |
the seed value range from 0 to 1 |
a |
the parameter ranging from 3.5 to 4 |
the map returns the a*x(1-x) for input x
logistic_map(0.26,3.5)
logistic_map(0.26,3.5)
this function generates random bits of desired length
prbits(n, Time = TRUE)
prbits(n, Time = TRUE)
n |
number of bits required |
Time |
it is a boolean value of TRUE/FALSE if we want to generate time dependent random bits.i.e each time we call the function with same input different output will be generated. |
returns a vector of random bits of length n
prbits(2) prbits(2) prbits(2,Time=FALSE) prbits(2,Time=FALSE) prbits(10)
prbits(2) prbits(2) prbits(2,Time=FALSE) prbits(2,Time=FALSE) prbits(10)
This function generates random numbers from standard cauchy distribution
prcauchy(n, Time = TRUE)
prcauchy(n, Time = TRUE)
n |
How many numbers we want |
Time |
time dependent or not |
a vector of n numbers from cauchy distribution
prcauchy(10) prcauchy(10,Time=TRUE) prcauchy(10,Time=TRUE)
prcauchy(10) prcauchy(10,Time=TRUE) prcauchy(10,Time=TRUE)
This function generates random numbers from exponentail distribution
prexp(n, Time = TRUE)
prexp(n, Time = TRUE)
n |
how many numbers we need |
Time |
time dependent or not |
a vector of n numbers from exponential distribution
prexp(10) prexp(10) prexp(10,FALSE) prexp(10,FALSE)
prexp(10) prexp(10) prexp(10,FALSE) prexp(10,FALSE)
Generating numbers form Normal distribution here we use Box Muler transform to obtain normal random variable
prnorm(n)
prnorm(n)
n |
number required |
a list of pseudo random numbers from normal distribution
prnorm(10) prnorm(100)
prnorm(10) prnorm(100)
this function generates random numbers which follow uniform distribution [0,1]
prunf( N = 100, Time = TRUE, n0 = 5, x00 = 0.5362, x01 = 0.357, x02 = 0.235, a1 = 3.69, a2 = 0.7 )
prunf( N = 100, Time = TRUE, n0 = 5, x00 = 0.5362, x01 = 0.357, x02 = 0.235, a1 = 3.69, a2 = 0.7 )
N |
How many numbers are required |
Time |
if enabled TRUE the numbers are time dependent |
n0 |
seed value of linear congruence map it can take value of any natural number |
x00 |
seed value of saw-tooth map values from 0 to 1 |
x01 |
seed value of logistic map values from 0 to 1 |
x02 |
seed value of baker map |
a1 |
parameter of logistic map the value takes from 3.5 to 4 |
a2 |
parameter of baker map the value it takes values greater than or equalt to 0.5 |
gives a vector of pseudo random numbers generated of desired length
prunf(10) prunf(10,Time=TRUE) prunf(10,Time=TRUE) prunf(10,Time=TRUE) prunf(10,2) prunf(10,Time=TRUE,2) prunf(10,Time=TRUE,2) prunf(10,5,0.52) prunf(15,2,0.352) prunf(10,2,0.652,0.235) prunf(10,Time=TRUE,2,0.652,0.235) prunf(9,7,0.52,0.4235,0.389) prunf(10,Time=TRUE,2,0.752,0.235,0.351,3.8)
prunf(10) prunf(10,Time=TRUE) prunf(10,Time=TRUE) prunf(10,Time=TRUE) prunf(10,2) prunf(10,Time=TRUE,2) prunf(10,Time=TRUE,2) prunf(10,5,0.52) prunf(15,2,0.352) prunf(10,2,0.652,0.235) prunf(10,Time=TRUE,2,0.652,0.235) prunf(9,7,0.52,0.4235,0.389) prunf(10,Time=TRUE,2,0.752,0.235,0.351,3.8)
saw tooth map is a family of maps as f(x)=b*x mod1
saw_tooth(x0)
saw_tooth(x0)
x0 |
seed value ranging from 0 to 1 |
(3*x) mod(1)
saw_tooth(0.6)
saw_tooth(0.6)
This function is used to generate a time of the system to be used for generating time dependent random numbers precise upto micro-seconds
stime()
stime()
t fractional value of the time
stime()
stime()