00001 #include "MTStation.h"
00002 #include <boost/random/lagged_fibonacci.hpp>
00003 #include <boost/random/normal_distribution.hpp>
00004 #include <boost/random/uniform_int.hpp>
00005 #include <boost/random/uniform_real.hpp>
00006 #include <boost/random/variate_generator.hpp>
00007 #include <boost/generator_iterator.hpp>
00008 #include <vector>
00009 #include <iostream>
00010 #include <ctime>
00011 #include <complex>
00012 #include <algorithm>
00013 #include <numeric>
00014 #include <cmath>
00015 #include <fstream>
00016 #include "Jacknife.h"
00017 #include "Bootstrap.h"
00018 #include "MTTensor.h"
00019 #include <time.h>
00020
00021 void wait ( int seconds )
00022 {
00023 clock_t endwait;
00024 endwait = time (0) + seconds ;
00025 while (time(0) < endwait) {}
00026 }
00027
00028 double CalcRhoa(const std::complex<double> Z, const double frequency)
00029 {
00030 return 1./(2 * PI * frequency) * mu * (pow(Z.real(),2)+pow(Z.imag(),2)) * pow(1000.0,2);
00031
00032 }
00033
00034
00035 int main()
00036 {
00037 int nsamples =1000;
00038
00039 std::cout<< "Number of samples: " ;
00040 std::cin >> nsamples;
00041
00042 std::vector<double> RhoValues(nsamples);
00043 boost::lagged_fibonacci607 generator(static_cast<unsigned int>(std::time(0)));
00044
00045 CMTStation Station;
00046
00047 Station.GetData("bel.mtt");
00048 CJacknife Jacknife(nsamples);
00049 wait(2);
00050 CBootstrap Bootstrap(nsamples);
00051 double JackMean, JackVar;
00052 double BootMean, BootVar;
00053 Jacknife.CalcErrors(&MTTensor::GetRhoxy,Station.GetMTData().at(0),JackMean,JackVar);
00054 Bootstrap.CalcErrors(&MTTensor::GetRhoxy,Station.GetMTData().at(0),BootMean,BootVar);
00055 const double Zerr = Station.GetMTData().at(0).GetdZxy();
00056 const double frequency = Station.GetMTData().at(0).GetFrequency();
00057 const std::complex<double> Zmean(Station.GetMTData().at(0).GetZxy());
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 double drhoa = 1./(PI * frequency) * mu * abs(Zmean) * Zerr * pow(1000.0,2);
00103 double rhoa = CalcRhoa(Zmean,frequency);
00104 std::cout << "Propmean: " << rhoa << " Properr: " << drhoa << std::endl;
00105 std::cout << "Jackmean: " << JackMean << " Jackerr: " << JackVar << std::endl;
00106 std::cout << "Bootmean: " << BootMean << " Booterr: " << BootVar << std::endl;
00107 }