mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-27 02:30:53 +00:00
36 lines
723 B
Mathematica
36 lines
723 B
Mathematica
|
|
||
|
#include <objects/Random.h>
|
||
|
#include <objects/RNGBerkeley.h>
|
||
|
#include <objects/RNGAdditiveCongruential.h>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
id r;
|
||
|
id rng;
|
||
|
int i;
|
||
|
|
||
|
r = [[Random alloc] init];
|
||
|
printf("float\n");
|
||
|
for (i = 0; i < 20; i++)
|
||
|
printf("%f\n", [r randomFloat]);
|
||
|
printf("doubles\n");
|
||
|
for (i = 0; i < 20; i++)
|
||
|
printf("%f\n", [r randomDouble]);
|
||
|
|
||
|
rng = [[RNGBerkeley alloc] init];
|
||
|
printf("%s chi^2 = %f\n",
|
||
|
[rng name], [Random chiSquareOfRandomGenerator:rng]);
|
||
|
[r release];
|
||
|
|
||
|
rng = [[RNGAdditiveCongruential alloc] init];
|
||
|
/*
|
||
|
for (i = 0; i < 50; i++)
|
||
|
printf("%ld\n", [r nextRandom]);
|
||
|
*/
|
||
|
printf("%s chi^2 = %f\n",
|
||
|
[rng name], [Random chiSquareOfRandomGenerator:rng]);
|
||
|
[rng release];
|
||
|
|
||
|
exit(0);
|
||
|
}
|