Download the PHP package qmegas/php-rand-custom-distribution without Composer
On this page you can find all versions of the php package qmegas/php-rand-custom-distribution. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download qmegas/php-rand-custom-distribution
More information about qmegas/php-rand-custom-distribution
Files in qmegas/php-rand-custom-distribution
Download qmegas/php-rand-custom-distribution
More information about qmegas/php-rand-custom-distribution
Files in qmegas/php-rand-custom-distribution
Vendor qmegas
Package php-rand-custom-distribution
Short Description Random number generator with custom distribution
License MIT
Package php-rand-custom-distribution
Short Description Random number generator with custom distribution
License MIT
Please rate this library. Is it a good library?
Informations about the package php-rand-custom-distribution
Random number generator with custom distribution
Standard PHP functions like rand
or mt_rand
generate random numbers with normal distribution, however sometimes it
required to generate random numbers with different distribution, for example binomial distribution.
Installation
Requirements
PHP >= 7.0
Simple Example
Class constractor receives 3 arguments: low-high bounds of generated numbers and distribution function. Distribution function receives float argument between 0 and 1 and should return some integer value >= 0, see additional examples for better understanding.
Some Additional Examples
Normal Distribution |
$generator = new \Qmegas\RandomGenerator($min, $max, function() {
return 1;
});
|
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
return $i * 100;
});
|
|
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
return (1 - $i) * 100;
});
|
|
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
return (1 - $i) * 200 * $i;
});
|
|
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
return (2 * (1 - $i) * ($i ** 0.5) + ($i ** 2)) * 100;
});
|
|
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
return ($i ** 3) * 100;
});
|
|
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
return (3 * ((1 - $i) ** 2) * $i + ($i ** 3)) * 100;
});
|
|
$generator = new \Qmegas\RandomGenerator($min, $max, function(float $i) {
return (1 / (1 + exp(-10 * ($i - 0.5)))) * 100;
});
|
All versions of php-rand-custom-distribution with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.0
The package qmegas/php-rand-custom-distribution contains the following files
Loading the files please wait ....