npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
assignResamplingWeights.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_ASSIGNRESAMPLINGWEIGHTS_HH_
2 #define NPSTAT_ASSIGNRESAMPLINGWEIGHTS_HH_
3 
4 /*!
5 // \file assignResamplingWeights.hh
6 //
7 // \brief Resampling with replacement which assigns weights to point locations
8 //
9 // Author: I. Volobouev
10 //
11 // July 2022
12 */
13 
14 #include <vector>
15 
17 
18 namespace npstat {
19  /**
20  // Imagine that you have a sample of size "nPoints".
21  // If you would resample it with replacement in the
22  // usuall manner, some points would be chosen a few
23  // times, and some not at all. On output of this function,
24  // the vector "weightsToFill" will be filled with counts
25  // how many times each point of the sample is chosen.
26  // Naturally, the size of the "weightsToFill" vector
27  // will be set to "nPoints".
28  //
29  // This is an alternative representation of the resampling
30  // procedure which can be useful in certain scenarios.
31  */
33  unsigned long nPoints,
34  unsigned long sampleSizeWanted,
35  std::vector<double>* weightsToFill);
36 
37 #ifdef SWIG
38  inline std::vector<double> assignResamplingWeights2(
39  AbsRandomGenerator& gen, const unsigned long nPoints,
40  const unsigned long sampleSizeWanted)
41  {
42  std::vector<double> to;
43  assignResamplingWeights(gen, nPoints, sampleSizeWanted, &to);
44  return to;
45  }
46 #endif
47 }
48 
49 #endif // NPSTAT_ASSIGNRESAMPLINGWEIGHTS_HH_
Interface definition for pseudo- and quasi-random number generators.
Definition: AbsArrayProjector.hh:14
void assignResamplingWeights(AbsRandomGenerator &gen, unsigned long nPoints, unsigned long sampleSizeWanted, std::vector< double > *weightsToFill)
Definition: AbsRandomGenerator.hh:27