#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <math.h>
#include <assert.h>
#include "cdflib.h"
#include "random.h"

/* dump_vector: print the contents of a vector in a file */

void dump_vector (Vector *vector, char *filename) {
  FILE *fp = fopen(filename, "w");
  print_vector_fp (vector, fp);
}


void test_uniform(int n) {
  int i;
  double x;
  Vector *dist = make_vector(n);

  for (i=0; i<n; i++) {
    x = rand_uniform() * 30.0;
    add_to_vector(dist, x);
  }
  dump_vector (dist, "rand.uniform");
}


void test_normal(int n) {
  int i;
  double x;
  Vector *dist = make_vector(n);

  for (i=0; i<n; i++) {
    x = rand_normal() * 15.0 + 15.0;
    add_to_vector(dist, x);
  }
  dump_vector (dist, "rand.normal");
}


void test_lognormal(int n) {
  int i;
  double x;
  Vector *dist = make_vector(n);

  for (i=0; i<n; i++) {
    x = rand_lognormal(1.0, 1.85);
    add_to_vector(dist, x);
  }
  dump_vector (dist, "rand.lognormal");
}


void test_exponential(int n) {
  int i;
  double x;
  Vector *dist = make_vector(n);

  for (i=0; i<n; i++) {
    x = rand_exp(1.0/15.0);
    add_to_vector(dist, x);
  }
  dump_vector (dist, "rand.exponential");
}


void test_pareto(int n) {
  int i;
  double x;
  Vector *dist = make_vector(n);

  for (i=0; i<n; i++) {
    x = rand_pareto(7.0, 2.0);
    add_to_vector(dist, x);
  }
  dump_vector (dist, "rand.pareto");
}


int main (int argc, char *argv[]) {
  int n = 10000;

  test_uniform (n);
  test_normal (n);
  test_lognormal (n);
  test_exponential (n);
  test_pareto (n);
  return 0;
}

