mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-06-19 07:47:05 +01:00
histogram class and associated plotting functions
This commit is contained in:
@ -1,19 +1,25 @@
|
||||
#include <iostream>
|
||||
#include <LatAnalyze/AsciiFile.hpp>
|
||||
#include <LatAnalyze/CompiledFunction.hpp>
|
||||
#include <LatAnalyze/Plot.hpp>
|
||||
#include <LatAnalyze/RandGen.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace Latan;
|
||||
|
||||
const int seqLength = 25;
|
||||
const int saveStep = 9;
|
||||
const string stateFileName = "exRand.seed";
|
||||
constexpr int seqLength = 25;
|
||||
constexpr int saveStep = 9;
|
||||
constexpr Index nDraw = 20000;
|
||||
const string stateFileName = "exRand.seed";
|
||||
|
||||
int main(void)
|
||||
{
|
||||
RandGenState state;
|
||||
RandGen gen[2];
|
||||
AsciiFile stateFile(stateFileName, File::Mode::write|File::Mode::read);
|
||||
RandGen gen[2];
|
||||
AsciiFile stateFile(stateFileName, File::Mode::write|File::Mode::read);
|
||||
DVec gauss(nDraw);
|
||||
Plot p;
|
||||
Histogram h;
|
||||
|
||||
cout << "- GENERATOR STATE I/O TESTS" << endl;
|
||||
cout << "-- generating a " << seqLength << " steps random sequence..."
|
||||
@ -38,5 +44,16 @@ int main(void)
|
||||
{
|
||||
cout << "step " << i << "\t: " << gen[1].uniform() <<endl;
|
||||
}
|
||||
cout << "-- generating " << nDraw << " Gaussian random numbers..." << endl;
|
||||
FOR_VEC(gauss, i)
|
||||
{
|
||||
gauss(i) = gen[0].gaussian();
|
||||
}
|
||||
h.setFromData(gauss, -5., 5., 40);
|
||||
h.normalize();
|
||||
p << PlotHistogram(h);
|
||||
p << PlotFunction(compile("return exp(-x_0^2/2)/sqrt(2*pi);", 1), -5., 5.);
|
||||
p.display();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user