1.1.0
CCC
 
Classical.cpp File Reference
#include "geoslib_old_f.h"
#include "Db/Db.hpp"
#include "Db/DbGrid.hpp"
#include "Stats/Classical.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/String.hpp"
#include "Basic/AStringable.hpp"
#include "Matrix/MatrixSquareSymmetric.hpp"
#include "Matrix/MatrixFactory.hpp"
#include "Model/Model.hpp"
#include "Space/SpaceRN.hpp"
#include "Space/SpaceTarget.hpp"
#include "Variogram/VarioParam.hpp"
#include "Variogram/Vario.hpp"
#include "Polygon/Polygons.hpp"
#include <math.h>
#include <Matrix/Table.hpp>
#include <string.h>

Functions

bool _operStatisticsCheck (const EStatOption &oper, int flag_multi, int flag_indic, int flag_sum, int flag_median, int flag_qt)
 
void _updateProportions (DbGrid *dbin, VectorInt &indg, int nfacies, VectorDouble &prop)
 
void _updateTransition (DbGrid *dbin, int pos, VectorInt &indg, int nfacies, int orient, VectorDouble &trans)
 
void _scaleAndAffect (Db *dbout, int iptr, int iech, int nitem, VectorDouble &tab)
 
bool _operExists (const std::vector< EStatOption > &opers, const EStatOption &refe)
 
void _refactor (int ncol, VectorDouble &tab)
 
void _copyResults (int nx, int ny, const VectorDouble &tabin, VectorDouble &tabout)
 
void _neighboringCell (int ndim, int radius, int rank0, const VectorInt &indg0, VectorInt &indg)
 
double _getQuantile (VectorDouble &tab, int ntab, double proba)
 
VectorString statOptionToName (const std::vector< EStatOption > &opers)
 
std::vector< EStatOption > KeysToStatOptions (const VectorString &opers)
 
void dbStatisticsVariables (Db *db, const VectorString &names, const std::vector< EStatOption > &opers, int iptr0, double proba, double vmin, double vmax)
 
Table dbStatisticsMono (Db *db, const VectorString &names, const std::vector< EStatOption > &opers, bool flagIso, double proba, double vmin, double vmax, const String &title)
 Compute one or several statistics (oper/opers) on a set of variables (names) contained in a Db and produce the results as a Table or as variables added to the input Db. More...
 
VectorDouble dbStatisticsFacies (Db *db)
 
double dbStatisticsIndicator (Db *db)
 
Table dbStatisticsCorrel (Db *db, const VectorString &names, bool flagIso, const String &title)
 Compute one or several statistics (oper/opers) on a set of variables (names) contained in a Db and produce the results as a Table or as variables added to the input Db. More...
 
int statisticsProportion (DbGrid *dbin, DbGrid *dbout, int pos, int nfacies, int radius)
 
int statisticsTransition (DbGrid *dbin, DbGrid *dbout, int pos, int nfacies, int radius, int orient)
 
void _getRowname (const String &radix, int ncol, int icol, const String &name, char *string)
 
void dbStatisticsPrint (const Db *db, const VectorString &names, const std::vector< EStatOption > &opers, bool flagIso, bool flagCorrel, const String &title, const String &radix)
 Compute one or several statistics (oper/opers) on a set of variables (names) contained in a Db and produce the results as a Table or as variables added to the input Db. More...
 
MatrixRectangularsphering (const AMatrix *X)
 
VectorDouble dbStatisticsPerCell (Db *db, DbGrid *dbgrid, const EStatOption &oper, const String &name1, const String &name2, const VectorDouble &cuts)
 Compute Statistics of points per cell. More...
 
Table dbStatisticsMulti (Db *db, const VectorString &names, const EStatOption &oper, bool flagMono, const String &title)
 Compute one or several statistics (oper/opers) on a set of variables (names) contained in a Db and produce the results as a Table or as variables added to the input Db. More...
 
int dbStatisticsInGridTool (Db *db, DbGrid *dbgrid, const VectorString &names, const EStatOption &oper, int radius, int iptr0)
 
VectorVectorInt correlationPairs (Db *db1, Db *db2, const String &name1, const String &name2, bool flagFrom1, bool verbose)
 
VectorVectorInt hscatterPairs (Db *db, const String &name1, const String &name2, VarioParam *varioparam, int ipas, int idir, bool verbose)
 
int correlationIdentify (Db *db1, Db *db2, int icol1, int icol2, Polygons *polygon)
 
VectorVectorDouble condexp (Db *db1, Db *db2, int icol1, int icol2, double mini, double maxi, int nclass, bool verbose)
 

Function Documentation

void _copyResults ( int  nx,
int  ny,
const VectorDouble tabin,
VectorDouble tabout 
)

Copy the multivariate or monovariate statistics into the returned array

Parameters
[in]nxFirst dimension of the matrix
[in]nyFirst dimension of the matrix
[in]tabinArray to be refactored
[out]taboutArray to be refactored
double _getQuantile ( VectorDouble tab,
int  ntab,
double  proba 
)

Calculate the quantile which corresponds to a given probability

Returns
Quantile value
Parameters
[in]tabArray of outcomes per sample
[in]ntabNumber of active values
[in]probaProbability value (between 0 and 1)
void _getRowname ( const String radix,
int  ncol,
int  icol,
const String name,
char *  string 
)

Constitute the name of the row

Parameters
[in]radixRadix for the different variables (optional)
[in]ncolNumber of variables
[in]icolRank of the variable
[in]nameVariables name
[in]stringString array
void _neighboringCell ( int  ndim,
int  radius,
int  rank0,
const VectorInt indg0,
VectorInt indg 
)

Calculate the indices of the cell neighboring a target cell

Parameters
[in]ndimSpace dimension
[in]radiusNeighborhood radius
[in]rank0Rank of the neighbor
[in]indg0Array of indices of the target cell
[out]indgArray of indices of the neighboring cell
bool _operExists ( const std::vector< EStatOption > &  opers,
const EStatOption &  refe 
)

Check the operator name is mentioned within a list

Returns
true if the operator is mentioned; false otherwise
Parameters
[in]opersArray of operators
[in]refeReference operator
Remarks
If the array 'opers' if empty, any name is considered as valid
bool _operStatisticsCheck ( const EStatOption &  oper,
int  flag_multi,
int  flag_indic,
int  flag_sum,
int  flag_median,
int  flag_qt 
)

Check the operator name

Returns
1 if the operator is valid; 0 otherwise
Parameters
[in]operA EStatOption item
[in]flag_multi1 if multivariate operator is authorized
[in]flag_indic1 if indicator ("plus","minus","zero") is authorized
[in]flag_sum1 if sum of variable is authorized
[in]flag_median1 if median is authorized
[in]flag_qt1 if QT ("ore","metal") is authorized
Remarks
If an error occurred, the message is printed
void _refactor ( int  ncol,
VectorDouble tab 
)

Copy the multivariate into monovariate statistics (before printout)

Parameters
[in]ncolDimension of the (square) matrix
[in,out]tabArray to be refactored
void _scaleAndAffect ( Db dbout,
int  iptr,
int  iech,
int  nitem,
VectorDouble tab 
)

Scale the proportions and store the proportions

Parameters
[in]dboutDb for the output grid
[in]iptrWriting pointer
[in]iechRank of the target sample
[in]nitemNumber of items
[in]tabArray of cumulative statistics
void _updateProportions ( DbGrid dbin,
VectorInt indg,
int  nfacies,
VectorDouble prop 
)

Update the proportions

Parameters
[in]dbinDb for the input grid
[in]indgArray of grid indices
[in]nfaciesNumber of facies
[out]propArray of proportions
void _updateTransition ( DbGrid dbin,
int  pos,
VectorInt indg,
int  nfacies,
int  orient,
VectorDouble trans 
)

Update the transitions

Parameters
[in]dbinDbGrid for the input grid
[in]posRank of the montee axis
[in]indgArray of grid indices
[in]nfaciesNumber of facies
[in]orientOrientation
[out]transArray of transitions
VectorVectorDouble condexp ( Db db1,
Db db2,
int  icol1,
int  icol2,
double  mini,
double  maxi,
int  nclass,
bool  verbose 
)

Evaluate the experimental conditional expectation

Parameters
[in]db1Db descriptor (for target variable)
[in]db2Db descriptor (for auxiliary variables)
[in]icol1Rank of the target variable
[in]icol2Rank of the explanatory variable
[in]miniMinimum value for the explanaroty variable
[in]maxiMaximum value for the explanaroty variable
[in]nclassNumber of classes
[in]verboseVerbose flag
int correlationIdentify ( Db db1,
Db db2,
int  icol1,
int  icol2,
Polygons polygon 
)

Identify samples from scatter plot when included within a polygon

Returns
Error return code
Parameters
[in]db1Db descriptor (first variable)
[in]db2Db descriptor (second variable for flag.same=T)
[in]icol1Rank of the first column
[in]icol2Rank of the second column
[in]polygonPolygons structure
Remarks
The two input Db must match exactly (same number of samples with
same set of coordinates and same optional selection)
VectorVectorInt correlationPairs ( Db db1,
Db db2,
const String name1,
const String name2,
bool  flagFrom1,
bool  verbose 
)

Evaluate the correlation Correl(Z1(x) , Z2(x))

Returns
Array of the indices of pairs of samples (or VectorVectorInt())
Parameters
[in]db1Db descriptor (first variable)
[in]db2Db descriptor (second variable for flag.same=T)
[in]name1Name of the first variable
[in]name2Name of the second variable
[in]flagFrom1Start numbering of indices from 1 if True
[in]verboseVerbose flag
Remarks
The two input Db must match exactly (same number of samples with
same set of coordinates and same optional selection)
The returned Vector of Vector of integer 'indices' contain
the set of indices of the pairs of samples.
Its contents is i1,j1,i2,j2,...
The indices are numbered starting from 0
VectorDouble dbStatisticsFacies ( Db db)

Considering that the Unique variable is a Facies (positive integer) returns the vector of proportions

Returns
The vector of proportions per Facies
Parameters
[in]dbDb structure
double dbStatisticsIndicator ( Db db)

Considering that the Unique variable is an Indicator (0 or 1) returns the proportion of 1

Returns
The vector of proportions per Facies
Parameters
[in]dbDb structure
int dbStatisticsInGridTool ( Db db,
DbGrid dbgrid,
const VectorString names,
const EStatOption &  oper,
int  radius,
int  iptr0 
)

Calculates the monovariate statistics within cells of a grid

Returns
Error return code
Parameters
[in]dbDb for the points
[in]dbgridDb for the grid
[in]namesVector of target variable names
[in]operA EStatOption item
[in]radiusNeighborhood radius
[in]iptr0Storage address (first variable)
VectorVectorInt hscatterPairs ( Db db,
const String name1,
const String name2,
VarioParam varioparam,
int  ipas,
int  idir,
bool  verbose 
)

Evaluate the shifted correlation calculated as follows: Correl(Z1(x) , Z2(x+h))

Returns
Vector of indices (or VectorVectorInt())
Parameters
[in]dbDb descriptor
[in]name1Name of the first variable
[in]name2Name of the second variable
[in]varioparampointer to a VarioParam structure
[in]ipasRank of the lag of interest
[in]idirRank of the direction of interest (within VarioParam)
[in]verboseVerbose flag
Remarks
The returned Vector of Vector of integer 'indices' contain
the set of indices of the pairs of samples.
Its contents is i1,j1,i2,j2,...
The indices are numbered starting from 1
std::vector<EStatOption> KeysToStatOptions ( const VectorString opers)
MatrixRectangular* sphering ( const AMatrix X)

Sphering procedure

Parameters
XInput Data vector
Returns
The Sphering matrix (or nullptr if problem)
Remarks
When performing the (forward) sphering, you must perform the following operation
X <- prodMatMat(X, S)
int statisticsProportion ( DbGrid dbin,
DbGrid dbout,
int  pos,
int  nfacies,
int  radius 
)

Calculates the "montee" from a grid into a 1-D grid

Returns
Error return code
Parameters
[in]dbinDb for the input grid
[in]dboutDb for the output grid
[in]posRank of the montee axis (starting from 0)
[in]nfaciesNumber of facies
[in]radiusRadius of the neighborhood
int statisticsTransition ( DbGrid dbin,
DbGrid dbout,
int  pos,
int  nfacies,
int  radius,
int  orient 
)

Calculates the transition from a grid into a 1-D grid

Returns
Error return code
Parameters
[in]dbinDb for the input grid
[in]dboutDb for the output grid
[in]posRank of the montee axis (starting from 0)
[in]nfaciesNumber of facies
[in]radiusRadius of the neighborhood
[in]orientOrientation (+1 or -1)
VectorString statOptionToName ( const std::vector< EStatOption > &  opers)