#include <iostream>
#include <fstream>
#include <math.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_statistics_double.h>
#include <gsl/gsl_histogram.h>
Go to the source code of this file.
Definition at line 17 of file testOneDConductionExactMC.cpp.
References NCELLS, NTRIES, and sqrt().
19 gsl_rng *r = gsl_rng_alloc(gsl_rng_taus);
20 gsl_rng_set(r,455465636);
24 double **Tc =
new double*[
NCELLS];
25 double *xc =
new double[
NCELLS];
26 for(
int c=0; c<
NCELLS; c++)
27 Tc[c] =
new double[
NTRIES];
32 for(
int c=1; c<
NCELLS; c++)
38 double e = (gsl_ran_ugaussian(r)*sigma1 +0.);
40 double ln_term = log(1 + e);
41 for(
int c=0; c<
NCELLS; c++)
49 Tc[c][i] = log(1+e*xc[c])/ln_term;
56 ofstream mean_file, sd_file;
57 mean_file.open(
"/tmp/mean-mc.dat");
58 sd_file.open(
"/tmp/sd-mc.dat");
60 for(
int c=0; c<
NCELLS; c++)
62 double Tmean = gsl_stats_mean(Tc[c],1,NTRIES);
63 double Tvariance = gsl_stats_variance_m(Tc[c],1,NTRIES,Tmean);
64 mean_file << xc[c] <<
" " << Tmean << endl;
65 sd_file << xc[c] <<
" " <<
sqrt(Tvariance) << endl;
Tangent sqrt(const Tangent &a)