gstlearn  1.0.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 "Model/Model.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)
 

Function Documentation

◆ _copyResults()

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

◆ _getQuantile()

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)

◆ _getRowname()

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

◆ _neighboringCell()

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

◆ _operExists()

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

◆ _operStatisticsCheck()

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

◆ _refactor()

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

◆ _scaleAndAffect()

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

◆ _updateProportions()

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

◆ _updateTransition()

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

◆ dbStatisticsFacies()

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

◆ dbStatisticsIndicator()

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

◆ dbStatisticsInGridTool()

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)

◆ KeysToStatOptions()

std::vector<EStatOption> KeysToStatOptions ( const VectorString opers)

◆ sphering()

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 <- prodMatrix(X, S)

◆ statisticsProportion()

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

◆ statisticsTransition()

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)

◆ statOptionToName()

VectorString statOptionToName ( const std::vector< EStatOption > &  opers)