#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include"dSFMT.h"

dsfmt_t dsfmt1;
#define Number 2000
#define width	1


int double_comp(const void *_a, const void *_b) {	//for qsort
	double a = *(double *)_a;
	double b = *(double *)_b;
	
	if (a > b)		return 1;
	else if (a < b)	return -1;
	else			return 0;
}


double rand_gauss( double mu , double sigma ){	//rand : gauss
	double x1 = dsfmt_genrand_close_open(&dsfmt1);
	double x2 = dsfmt_genrand_close_open(&dsfmt1);
	double y  = sigma * ( sqrt(-2 * log(x1) ) * cos( 2*M_PI * x2)) + mu;
	return y;
}

int main(void){
	dsfmt_init_gen_rand(&dsfmt1,0);
	
	int i;
	double x,y;
	double X,Y;
	
	FILE *fp , *fp2;
	if( (fp = fopen("XY.dat", "w")) == NULL){
		printf("File Error\n");
		exit(1);
	}
	
	for( i = 0 ; i< Number ; i++){ //generate the number
		x = rand_gauss( 0 , 1);
		y = rand_gauss( 0 , 1);
		
		X = 2 * x;
		Y = 1.5 * x + 3.0 * y;
		
		fprintf(fp , "%f	%f\n", X,Y);
	}
	
	
	
	fclose(fp);
	return 0;
}



