#include "libscl.h"
using namespace scl;
using namespace std;

int main(int argc, char** argp, char** envp)
{
  REAL theta = 5;
  INT_32BIT seed = 770116;
  INTEGER n=10000;
  string filename="sims_5.dat";
  ofstream fout;
  fout.open(filename.c_str());
  if (!fout) error("Error, cannot open " + filename);
  REAL mean = 0.0;
  for (INTEGER i=1; i<=n; ++i) {
    REAL u = ran(seed);
    REAL x = pow(-log(1-u),(1.0/theta));  
    fout << fmt('e',27,16,x) << '\n';
    mean += pow(x,theta);
  }
  fout.clear(); fout.close();
  mean /= n;
  cout << '\n' << "mean x^theta = " << mean << '\n';
  return 0;
}
