mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-06-18 07:17:05 +01:00
internal random generator entirely removed, use C++11 generators
This commit is contained in:
@ -7,17 +7,12 @@ endif
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = \
|
||||
latan_create_rg_state \
|
||||
latan_make_fake_sample\
|
||||
latan_sample_combine \
|
||||
latan_sample_plot_corr\
|
||||
latan_sample_read \
|
||||
latan_resample
|
||||
|
||||
latan_create_rg_state_SOURCES = create_rg_state.cpp
|
||||
latan_create_rg_state_CXXFLAGS = $(COM_CXXFLAGS)
|
||||
latan_create_rg_state_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||
|
||||
latan_make_fake_sample_SOURCES = make_fake_sample.cpp
|
||||
latan_make_fake_sample_CXXFLAGS = $(COM_CXXFLAGS)
|
||||
latan_make_fake_sample_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* create_rg_state.cpp, part of LatAnalyze 3
|
||||
*
|
||||
* Copyright (C) 2013 - 2015 Antonin Portelli
|
||||
*
|
||||
* LatAnalyze 3 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LatAnalyze 3 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <LatAnalyze/Io.hpp>
|
||||
#include <LatAnalyze/RandGen.hpp>
|
||||
|
||||
using namespace Latan;
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
string outFilename;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
cerr << "usage: " << argv[0] << " <output file>" << endl;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
outFilename = argv[1];
|
||||
|
||||
RandGen gen;
|
||||
|
||||
Io::save(gen.getState(), outFilename);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <LatAnalyze/Io.hpp>
|
||||
#include <LatAnalyze/RandGen.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace Latan;
|
||||
@ -42,8 +41,10 @@ int main(int argc, char *argv[])
|
||||
nSample = strTo<Index>(argv[3]);
|
||||
outFileName = argv[4];
|
||||
|
||||
RandGen gen;
|
||||
DSample res(nSample);
|
||||
random_device rd;
|
||||
mt19937 gen(rd());
|
||||
normal_distribution<> dis(val, err);
|
||||
DSample res(nSample);
|
||||
|
||||
FOR_STAT_ARRAY(res, s)
|
||||
{
|
||||
@ -53,7 +54,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
res[s] = gen.gaussian(val, err);
|
||||
res[s] = dis(gen);
|
||||
}
|
||||
}
|
||||
Io::save<DSample>(res, outFileName);
|
||||
|
@ -34,7 +34,7 @@ using namespace Latan;
|
||||
static void usage(const string &cmdName)
|
||||
{
|
||||
cerr << "usage: " << cmdName;
|
||||
cerr << " [-n <nsample> -b <bin size> -r <state> -o <output dir> -f {h5|sample}]";
|
||||
cerr << " [-n <nsample> -b <bin size> -r <seed> -o <output dir> -f {h5|sample}]";
|
||||
cerr << " <data list> <name list>";
|
||||
cerr << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
@ -43,10 +43,12 @@ static void usage(const string &cmdName)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// argument parsing ////////////////////////////////////////////////////////
|
||||
int c;
|
||||
string manFileName, nameFileName, stateFileName, cmdName, outDirName = ".";
|
||||
string ext = "h5";
|
||||
Index binSize = 1, nSample = DEF_NSAMPLE;
|
||||
int c;
|
||||
random_device rd;
|
||||
SeedType seed = rd();
|
||||
string manFileName, nameFileName, cmdName, outDirName = ".";
|
||||
string ext = "h5";
|
||||
Index binSize = 1, nSample = DEF_NSAMPLE;
|
||||
|
||||
opterr = 0;
|
||||
cmdName = basename(argv[0]);
|
||||
@ -64,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
outDirName = optarg;
|
||||
break;
|
||||
case 'r':
|
||||
stateFileName = optarg;
|
||||
seed = strTo<SeedType>(optarg);
|
||||
break;
|
||||
case 'f':
|
||||
ext = optarg;
|
||||
@ -126,25 +128,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
// data resampling /////////////////////////////////////////////////////////
|
||||
DMatSample s(nSample);
|
||||
RandGen g;
|
||||
RandGenState state;
|
||||
|
||||
cout << "-- resampling data..." << endl;
|
||||
if (!stateFileName.empty())
|
||||
{
|
||||
state = Io::load<RandGenState>(stateFileName);
|
||||
}
|
||||
for (unsigned int i = 0; i < name.size(); ++i)
|
||||
{
|
||||
const string outFileName = name[i] + "_" + manFileName + "." + ext;
|
||||
|
||||
cout << '\r' << ProgressBar(i + 1, name.size());
|
||||
data[name[i]].bin(binSize);
|
||||
if (!stateFileName.empty())
|
||||
{
|
||||
g.setState(state);
|
||||
}
|
||||
s = data[name[i]].bootstrapMean(nSample, g);
|
||||
s = data[name[i]].bootstrapMean(nSample, seed);
|
||||
Io::save<DMatSample>(s, outDirName + "/" + outFileName,
|
||||
File::Mode::write, outFileName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user