openGPMP
Open Source Mathematics Package
resampling.hpp
Go to the documentation of this file.
1 /*************************************************************************
2  *
3  * Project
4  * _____ _____ __ __ _____
5  * / ____| __ \| \/ | __ \
6  * ___ _ __ ___ _ __ | | __| |__) | \ / | |__) |
7  * / _ \| '_ \ / _ \ '_ \| | |_ | ___/| |\/| | ___/
8  *| (_) | |_) | __/ | | | |__| | | | | | | |
9  * \___/| .__/ \___|_| |_|\_____|_| |_| |_|_|
10  * | |
11  * |_|
12  *
13  * Copyright (C) Akiel Aries, <akiel@akiel.org>, et al.
14  *
15  * This software is licensed as described in the file LICENSE, which
16  * you should have received as part of this distribution. The terms
17  * among other details are referenced in the official documentation
18  * seen here : https://akielaries.github.io/openGPMP/ along with
19  * important files seen in this project.
20  *
21  * You may opt to use, copy, modify, merge, publish, distribute
22  * and/or sell copies of the Software, and permit persons to whom
23  * the Software is furnished to do so, under the terms of the
24  * LICENSE file.
25  *
26  *
27  *
28  * This software is distributed on an AS IS basis, WITHOUT
29  * WARRANTY OF ANY KIND, either express or implied.
30  *
31  ************************************************************************/
32 #ifndef RESAMPLING_HPP
33 #define RESAMPLING_HPP
34 
35 #include <algorithm>
36 #include <random>
37 #include <stdexcept>
38 #include <vector>
39 
40 namespace gpmp {
41 
42 namespace stats {
43 
48 class Resampling {
49  public:
56  static std::vector<int> bootstrap(const std::vector<int> &data,
57  int numSamples);
58 
65  static std::vector<int> subsample(const std::vector<int> &data,
66  int numSamples);
67 
73  static std::vector<std::vector<int>>
74  jackknife(const std::vector<int> &data);
75 
82  static std::vector<std::vector<int>>
83  permutation_test(const std::vector<int> &data, int numPermutations);
84 
91  static std::vector<double> bootstrap_t(const std::vector<double> &data,
92  int numSamples);
93 
102  static std::pair<double, double>
103  bootstrap_ci(const std::vector<double> &data, double alpha, int numSamples);
104 
111  static std::vector<double>
112  smoothed_bootstrap(const std::vector<double> &data, int numSamples);
113 
121  static std::vector<double>
122  circular_block_bootstrap(const std::vector<double> &data,
123  int blockSize,
124  int numSamples);
125 
132  static std::vector<double>
133  time_series_bootstrap(const std::vector<double> &data, int numSamples);
134 
142  static std::vector<double>
143  weighted_bootstrap(const std::vector<double> &data,
144  const std::vector<double> &weights,
145  int size);
146 
154  static double permutation_p_value(const std::vector<double> &data1,
155  const std::vector<double> &data2,
156  double observedStatistic);
157 };
158 } // namespace stats
159 } // namespace gpmp
160 
161 #endif
A class providing various resampling methods for statistical analysis.
Definition: resampling.hpp:48
static std::vector< double > bootstrap_t(const std::vector< double > &data, int numSamples)
Perform bootstrap t-statistic resampling.
Definition: resampling.cpp:111
static std::vector< double > circular_block_bootstrap(const std::vector< double > &data, int blockSize, int numSamples)
Perform circular block bootstrap resampling.
Definition: resampling.cpp:171
static std::vector< double > smoothed_bootstrap(const std::vector< double > &data, int numSamples)
Perform smoothed bootstrap resampling.
Definition: resampling.cpp:150
static std::vector< double > weighted_bootstrap(const std::vector< double > &data, const std::vector< double > &weights, int size)
Perform weighted bootstrap resampling.
Definition: resampling.cpp:233
static std::vector< int > subsample(const std::vector< int > &data, int numSamples)
Perform subsampling.
Definition: resampling.cpp:58
static std::vector< double > time_series_bootstrap(const std::vector< double > &data, int numSamples)
Perform time series bootstrap resampling.
Definition: resampling.cpp:208
static double permutation_p_value(const std::vector< double > &data1, const std::vector< double > &data2, double observedStatistic)
Calculate the p-value using permutation test.
Definition: resampling.cpp:247
static std::vector< std::vector< int > > jackknife(const std::vector< int > &data)
Perform jackknife resampling.
Definition: resampling.cpp:77
static std::vector< std::vector< int > > permutation_test(const std::vector< int > &data, int numPermutations)
Perform permutation test.
Definition: resampling.cpp:93
static std::pair< double, double > bootstrap_ci(const std::vector< double > &data, double alpha, int numSamples)
Calculate confidence interval using bootstrap.
Definition: resampling.cpp:137
static std::vector< int > bootstrap(const std::vector< int > &data, int numSamples)
Perform bootstrap resampling.
Definition: resampling.cpp:40
The source C++ openGPMP namespace.