English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Sampler: URANIE::Sampler::TBasicSampling Class Reference
Uranie / Sampler v4.9.0
/* @license-end */
URANIE::Sampler::TBasicSampling Class Reference

Description of the class TBasicSampling. More...

#include <TBasicSampling.h>

Inheritance diagram for URANIE::Sampler::TBasicSampling:
Collaboration diagram for URANIE::Sampler::TBasicSampling:

Public Types

enum  EType { kLHS , kSRS , kUnknown }
 

Public Member Functions

Constructor and Destructor
 TBasicSampling (URANIE::DataServer::TDataServer *tds, Option_t *option="lhs", Int_t sampleSize=1000)
 
virtual ~TBasicSampling ()
 Default destructor.
 
Correlations
void setTolerance (Double_t tolerance)
 Set the precision of similarity

 
void setCorrelationMatrix (TMatrixD corrMat)
 Set the correlation matrix.
 
void setUserCorrelation (TString attName1, TString attName2, Double_t corrValue)
 Set user correlation for two attributes.
 
void findSimilar ()
 Locate totally correlated attributes.
 
Generate the sample
void generateCorrSample (Option_t *option="")
 Generates correlated data following a user defined correlation matrix.
 
void generateSample (Option_t *option="")
 Generates the sample.
 
virtual void fillOtherAttributes ()
 Fills the TAttributeFormula and totally correlated attributes.
 
Printing Log
virtual void printLog (Option_t *option="")
 Prints the log.
 
- Public Member Functions inherited from URANIE::Sampler::TSamplerStochastic
 TSamplerStochastic (URANIE::DataServer::TDataServer *tds, Option_t *option, Int_t nCalcul)
 Constructor with a dataserver.
 
virtual ~TSamplerStochastic ()
 Default destructor.
 
void setSeed (Int_t ind=0)
 Init the seed.
 
Int_t getSeed ()
 Returns the seed value.
 
- Public Member Functions inherited from URANIE::Sampler::TSampler
 TSampler (URANIE::DataServer::TDataServer *tds, Option_t *option, Int_t nCalcul)
 Constructor with a TDataServer, the options and the size of the sample.
 
virtual ~TSampler ()
 Default destructor.
 
Int_t GetID ()
 Returns the ID of the class.
 
void setMethodName (TString str)
 Sets the method name in a global variable.
 
TString getMethodName ()
 Gets the method name.
 
virtual URANIE::DataServer::TDataServer * getTDS ()
 Return the TDS filling by the sampling algorithm.
 
void parseOption (Option_t *option)
 Parse the option.
 
virtual void createListOfAttributes ()
 Creates the List of attributes to simulate.
 
virtual void createTuple ()
 Creates the TDSNtupleD of data with only the TStochasticAttributes.
 
URANIE::DataServer::TDSNtupleD * getTuple ()
 Returns the TDSNtupleD of data.
 
void setLog ()
 
void unsetLog ()
 
void changeLog ()
 
Bool_t getLog ()
 

Public Attributes

LHSInput * _fLhsInput
 
EType _ntype
 The type of sampling (SRS, LHS)
 
TMatrixD userCorrMat
 correlation matrix defined by the user
 
TMatrixD _corrMat
 correlation matrix used internally
 
TList * _listOfSimilar
 list of attributes totally correlated with other attributes.
 
TList * _listOfFormulas
 list of formulas linking two totally correlated attributes.
 
Double_t _simTolerance
 precision to decide if a correlation is equal to 1.0 (or -1.0).
 
Bool_t bApplyUserCorrelation
 if true, correlated data are produced.
 
- Public Attributes inherited from URANIE::Sampler::TSampler
Int_t _nS
 The size of the sample.
 
Int_t _nX
 The size of attributes to sample.
 
URANIE::DataServer::TDSNtupleD * _ntsample
 the tntuple of data
 
TString _sMethod
 The title of the sampler method.
 
Bool_t _blog
 Log Printing.
 
Bool_t _bupdateFile
 Update the back up file when generating the attributeformula if there is some.
 
URANIE::DataServer::TDataServer * _tds
 Pointer to a TDS.
 
TList * _lstOfAttributesToSample
 The list of Stochastic Attributes to sample.
 

Additional Inherited Members

- Protected Member Functions inherited from URANIE::Sampler::TSamplerStochastic
virtual void init ()
 The preprocessing step.
 
virtual void terminate ()
 The post-processing step.
 
- Protected Attributes inherited from URANIE::Sampler::TSamplerStochastic
Int_t _nSeed
 

Detailed Description

Description of the class TBasicSampling.

This class defines a TSamplerStochastic object for fast random data generation.

This is a very simple implementation of the random sampling. It will generate a set of n values for each random variable defined in the given TDataServer object.

The main differences with the TSampling class are:

  1. No correlation can be imposed between the variables.
  2. The strict independence between the generated variables is not garanteed.
  3. There is no lower limit in the number of random samples that can be generated.
  4. The generation is much faster when dealing with a large number of attributes.

On any other aspects, the two classes have the same properties.

In short, if you have a large number of independent random variables to sample in a short time, you should use this class. Otherwise, use TSampling.

Member Enumeration Documentation

◆ EType

Enumerator
kLHS 
kSRS 
kUnknown 

Constructor & Destructor Documentation

◆ TBasicSampling()

URANIE::Sampler::TBasicSampling::TBasicSampling ( URANIE::DataServer::TDataServer *  tds,
Option_t *  option = "lhs",
Int_t  sampleSize = 1000 
)

Creates a TBasicSampling object from a TDataServer, a sampling method and the size of the sample to generate

The random variables to sample are the attributes of the TDataServer. These attributes must derive from the TStochasticAttribute class. The sampling method, given as an option, can be either "lhs" (Latin Hypercube Sampling) or "srs" (Simple Random Sampling). If none of these is given, "lhs" is chosen.

Parameters
tds(TDataServer *) pointer to the TDataServer.
option(Option_t *) option string containing the sampling method (Default = "lhs").
sampleSize(Int_t) number of values to generate for each random variable (Default = 1000).
Exceptions
UErrorExceptionsif sampleSize <= 0

References URANIE::Sampler::TSampler::_blog, _listOfFormulas, _listOfSimilar, _ntype, kLHS, kSRS, and URANIE::Sampler::TSampler::setMethodName().

◆ ~TBasicSampling()

URANIE::Sampler::TBasicSampling::~TBasicSampling ( )
virtual

Member Function Documentation

◆ fillOtherAttributes()

void URANIE::Sampler::TBasicSampling::fillOtherAttributes ( )
virtual

Fills the TAttributeFormula and totally correlated attributes.

Reimplemented from URANIE::Sampler::TSampler.

References _listOfFormulas, _listOfSimilar, URANIE::Sampler::TSampler::_tds, and URANIE::Sampler::TSampler::fillOtherAttributes().

Referenced by generateCorrSample(), and generateSample().

◆ findSimilar()

void URANIE::Sampler::TBasicSampling::findSimilar ( )

◆ generateCorrSample()

void URANIE::Sampler::TBasicSampling::generateCorrSample ( Option_t *  option = "")

Generates correlated data following a user defined correlation matrix.

This function uses the "normal copula" method (cf. S. Wang. "Aggregation of correlated risk portfolios: Models and algorithms". Proceedings of the Casualty Actuarial Society, LXXXV:848-939, 1998) to create correlated data. This method is equivalent to the Iman & Connover one, but is faster and easier to implement. However, it does not preserve the "LHS" distribution, and might perform worse than I&C on the reconstruction of the theoretical correlation.

In addition, this function automatically detects totally correlated variables, and handle them correctly.

References URANIE::Sampler::TSampler::_blog, _corrMat, URANIE::Sampler::TSampler::_lstOfAttributesToSample, URANIE::Sampler::TSampler::_nS, URANIE::Sampler::TSampler::_ntsample, _ntype, URANIE::Sampler::TSampler::_nX, URANIE::Sampler::TSampler::_tds, URANIE::Sampler::TSampler::createTuple(), fillOtherAttributes(), findSimilar(), kLHS, kSRS, URANIE::Sampler::TSampler::parseOption(), and shuffleInteger().

◆ generateSample()

void URANIE::Sampler::TBasicSampling::generateSample ( Option_t *  option = "")
virtual

◆ printLog()

void URANIE::Sampler::TBasicSampling::printLog ( Option_t *  option = "")
virtual

Prints the log.

Parameters
option(Option_t *) option string (Default = "")

Reimplemented from URANIE::Sampler::TSamplerStochastic.

References _fLhsInput, URANIE::Sampler::TSampler::_nS, URANIE::Sampler::TSampler::_nX, and URANIE::Sampler::TSampler::_sMethod.

◆ setCorrelationMatrix()

void URANIE::Sampler::TBasicSampling::setCorrelationMatrix ( TMatrixD  corrMat)

Set the correlation matrix.

References URANIE::Sampler::TSampler::_nX, and userCorrMat.

◆ setTolerance()

void URANIE::Sampler::TBasicSampling::setTolerance ( Double_t  tolerance)
inline

Set the precision of similarity

References _simTolerance.

◆ setUserCorrelation()

void URANIE::Sampler::TBasicSampling::setUserCorrelation ( TString  attName1,
TString  attName2,
Double_t  corrValue 
)

Set user correlation for two attributes.

References URANIE::Sampler::TSampler::_nX, URANIE::Sampler::TSampler::_tds, and userCorrMat.

Member Data Documentation

◆ _corrMat

TMatrixD URANIE::Sampler::TBasicSampling::_corrMat

correlation matrix used internally

Referenced by findSimilar(), and generateCorrSample().

◆ _fLhsInput

LHSInput* URANIE::Sampler::TBasicSampling::_fLhsInput

Referenced by printLog(), and ~TBasicSampling().

◆ _listOfFormulas

TList* URANIE::Sampler::TBasicSampling::_listOfFormulas

list of formulas linking two totally correlated attributes.

Referenced by fillOtherAttributes(), findSimilar(), TBasicSampling(), and ~TBasicSampling().

◆ _listOfSimilar

TList* URANIE::Sampler::TBasicSampling::_listOfSimilar

list of attributes totally correlated with other attributes.

Referenced by fillOtherAttributes(), findSimilar(), TBasicSampling(), and ~TBasicSampling().

◆ _ntype

EType URANIE::Sampler::TBasicSampling::_ntype

The type of sampling (SRS, LHS)

Referenced by generateCorrSample(), generateSample(), and TBasicSampling().

◆ _simTolerance

Double_t URANIE::Sampler::TBasicSampling::_simTolerance

precision to decide if a correlation is equal to 1.0 (or -1.0).

Referenced by findSimilar(), and setTolerance().

◆ bApplyUserCorrelation

Bool_t URANIE::Sampler::TBasicSampling::bApplyUserCorrelation

if true, correlated data are produced.

◆ userCorrMat

TMatrixD URANIE::Sampler::TBasicSampling::userCorrMat

correlation matrix defined by the user

Referenced by findSimilar(), setCorrelationMatrix(), and setUserCorrelation().