# include "data.h"

int gaussdeviate (int argc, char **argv) {
  
  int i, Npts;
  double mean, sigma;
  Vector *vec;

  if (argc != 5) goto usage;

  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) return (FALSE);    

  Npts = atoi (argv[2]);
  mean = atof (argv[3]);
  sigma = atof (argv[4]);

  vec[0].Nelements = Npts;
  REALLOCATE (vec[0].elements, float, Npts);

  gauss_init (2048);
  for (i = 0; i < Npts; i++) {
    vec[0].elements[i] = rnd_gauss (mean, sigma);
  }
  return (TRUE);

 usage:
  gprint (GP_ERR, "USAGE: gaussdeviate (vector) Npts mean sigma\n");
  return (FALSE);
    
}

double int_gauss (int i);

int gaussintegral (int argc, char **argv) {
  
  int i, Npts;
  double mean, sigma;
  Vector *vec;

  if (argc != 5) goto usage;

  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) return (FALSE);    

  Npts = atoi (argv[2]);
  mean = atof (argv[3]);
  sigma = atof (argv[4]);

  vec[0].Nelements = Npts;
  REALLOCATE (vec[0].elements, float, Npts);

  gauss_init (Npts);
  for (i = 0; i < Npts; i++) {
    vec[0].elements[i] = int_gauss (i);
  }
  return (TRUE);

 usage:
  gprint (GP_ERR, "USAGE: gaussintegral Npts mean sigma\n");
  return (FALSE);
    
}
