#!/usr/bin/perl
#
# Make perfect data with a 1-D gaussian

use POSIX;

$amp = 1.0;
$fwhm = 1.0;
$sigma = $fwhm / 2.35;
$calc_width_fwhm = 7.0;

$start_t = 0;
$end_t = 500.0;
$dt = 0.1;
for ($t = $start_t; $t < $end_t; $t += $dt) {

  if (rand() > 0.002) {
    $voltage = 0.0;
    printf " %8.3f  %8.3f \n", $t, $voltage;
  }
  else {
    $half_width_t = $calc_width_fwhm*$fwhm;
    $middle_t = $t + $half_width_t;
    $duration = 2.0*$half_width_t;
    $duration_t = 0;
    while ($t < $middle_t + $half_width_t) {
      $x = $t - $middle_t;
      $arg = 0.0 - ($x*$x)/2.0*$sigma*$sigma;
      $voltage = 1.0*exp($arg);
      printf " %8.3f  %8.3f \n", $t, $voltage;
      $t += $dt;
    }
  }
    

}


exit 0;

