#!/usr/bin/perl
use Getopt::Long;
use vars qw/$opt_noise $opt_nrec/;
GetOptions("help", "noise:f" , "nrec:i");
if (defined $opt_help){
  print "usage: make_mock_data.pl -noise {float between 0 and 1}
              -nrec {integer number or records to make} > outfile\n";
  exit(0);
}
$opt_noise=0. unless defined $opt_noise;
$opt_nrec=100 unless defined $opt_nrec;

print "\#Mock data with input length 3 and target length 2.\n";
print "\#Generated with random seed\n";
srand();
for ($i=1;$i<=$opt_nrec;$i++){
$x=-1+2*rand;
$y=-1+2*rand;
$z=-1+2*rand;
$noise=$opt_noise*(-1+2*rand());
$a=.3*$x+.3*$y+.3*$z+$noise; #a linear relation
$noise=$opt_noise*(-1+2*rand());
$b=.4*$y*$z+.4*$x**3+$noise; #a nonlinear relation
#$b=.3*$x-.3*$z;  #make linear data to see if svd is perfect
print "$x $y $z $a $b \n"; #print input vector, target vector in a line
}
