# 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]);

  ResetVector (vec, OPIHI_FLT, Npts);

  gauss_init (2048);
  for (i = 0; i < Npts; i++) {
    vec[0].elements.Flt[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]);

  ResetVector (vec, OPIHI_FLT, Npts);

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

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