File: simple.c

package info (click to toggle)
autoclass 3.3.4-6
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,844 kB
  • ctags: 994
  • sloc: ansic: 16,674; makefile: 123; sh: 98; cpp: 95; csh: 77
file content (39 lines) | stat: -rw-r--r-- 622 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
  simple - manufacture a simple test data set for multimix
*/

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

double gauss(void);

/*      return normally distributed random number (zero mean, unit variance) */
double gauss()
{       int i;
 double sum=0;
 for (i = 0; i < 12; i++) sum += rand();
 return sum/RAND_MAX - 6.;
}

int main()
{
  int threshold = RAND_MAX/3;
  int i;
  double x, y;

  for (i = 0; i < 1000; i++)
    {
      if (rand() < threshold)
	{
	  x = gauss();
	  y = gauss() + 4;
	}
      else
	{
	  x = gauss()*3 + 5;
	  y = gauss()*3 + 9;
	}
      printf("%6.5f %6.5f\n", x, y);
    }
}