ソース
// https://www.cepstrum.co.jp/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#define PI 3.141592653589793
#define SIMLEN 70000
float z1vec[SIMLEN];
float z2vec[SIMLEN];
//================================================================
// unsigned=uint32_t
unsigned xorshift1(unsigned seed) {
static unsigned y=0x0f35f05b;
if (seed!=0) y=seed;
y^=(y<<5);
y^=(y>>13);
y^=(y<<6);
return y;
}
//================================================================
// unsigned=uint32_t
unsigned xorshift2(unsigned seed) {
static unsigned y=0x5a35aa5b;
if (seed!=0) y=seed;
y^=(y<<9);
y^=(y>>11);
y^=(y<<19);
return y;
}
//================================================================
int main(void) {
unsigned i;
float x, y, length, angle, z1, z2;
for (i=0; i<SIMLEN; i=i+1) {
x=(double)xorshift1(0)/(double)UINT_MAX; // 0.0<x<=1.0
y=(double)xorshift2(0)/(double)UINT_MAX; // 0.0<y<=1.0
length=sqrt(-2.0*logf(x)); // 0.0<=length
angle=2.0*PI*y; // 0.0<angle<=2.0*PI
z1=length*cosf(angle);
z2=length*sinf(angle);
z1vec[i]=z1;
z2vec[i]=z2;
}
for (i=0; i<SIMLEN; i=i+1) printf("%12.8f %12.8f\n", z1vec[i], z2vec[i]);
}