/usr/include/openturns/Sample.hxx is in libopenturns-dev 1.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | // -*- C++ -*-
/**
* @brief The class Sample implements blank free samples
*
* Copyright 2005-2017 Airbus-EDF-IMACS-Phimeca
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef OPENTURNS_SAMPLE_HXX
#define OPENTURNS_SAMPLE_HXX
#include <iostream> // for std::ostream
#include "openturns/TypedInterfaceObject.hxx"
#include "openturns/Point.hxx"
#include "openturns/Description.hxx"
#include "openturns/Pointer.hxx"
#include "openturns/SampleImplementation.hxx"
#include "openturns/ResourceMap.hxx"
BEGIN_NAMESPACE_OPENTURNS
/**
* @class Sample
*/
class OT_API Sample
: public TypedInterfaceObject<SampleImplementation>
{
CLASSNAME;
public:
/* Some typedefs for easy reading */
public:
/** Factory of Sample from CSV file */
static Sample ImportFromCSVFile(const FileName & fileName,
const String & csvSeparator = ResourceMap::Get( "csv-file-separator" ));
/** Factory of Sample from Text file */
static Sample ImportFromTextFile(const FileName & fileName,
const String & separator = " ");
/** Export Sample into CSV file */
void exportToCSVFile(const FileName & fileName,
const String & csvSeparator = ResourceMap::Get( "csv-file-separator" )) const;
/** Export a sample as a matrix, one row by realization, in a format suitable to exchange with R. */
String streamToRFormat() const;
public:
/**
* Default constructor
* Build a Sample of 1 dimension and with size equal to 0
*/
Sample();
/** Constructor with size and dimension */
Sample(const UnsignedInteger size,
const UnsignedInteger dim);
/** Constructor from a Point (all elements are equal to the Point) */
Sample(const UnsignedInteger size,
const Point & point);
/** Partial copy constructor */
Sample(const Sample other,
const UnsignedInteger first,
const UnsignedInteger last);
#ifndef SWIG
/** Constructor from a collection of Point */
Sample(const Collection<Point> & coll);
/** Constructor from a collection of Indices */
Sample(const Collection<Indices> & coll);
#endif
/** Constructor from implementation */
Sample(const SampleImplementation & implementation);
private:
/** Constructor from implementation */
Sample(const Implementation & implementation);
public:
/** Comparison operator */
Bool operator ==(const Sample & other) const;
using TypedInterfaceObject<SampleImplementation>::operator ==;
/** Comparison operator */
Bool operator !=(const Sample & other) const;
#ifndef SWIG
NSI_point operator [] (const UnsignedInteger index);
NSI_const_point operator [] (const UnsignedInteger index) const;
NSI_point at (const UnsignedInteger index);
NSI_const_point at (const UnsignedInteger index) const;
Scalar & operator () (const UnsignedInteger i,
const UnsignedInteger j);
const Scalar & operator () (const UnsignedInteger i,
const UnsignedInteger j) const;
Scalar & at (const UnsignedInteger i,
const UnsignedInteger j);
const Scalar & at (const UnsignedInteger i,
const UnsignedInteger j) const;
void erase(SampleImplementation::iterator first, SampleImplementation::iterator last);
#endif
// These functions are only intended to be used by SWIG, DO NOT use them for your own purpose !
// INTENTIONALY NOT DOCUMENTED
const Scalar * __baseaddress__ () const;
UnsignedInteger __elementsize__ () const;
/** Whether the list contains the value val */
Bool contains(const Point & val) const;
void erase(const UnsignedInteger first,
const UnsignedInteger last);
void erase(const UnsignedInteger index);
/** erase the whole sample */
void clear();
/**
* String converter
* This method shows human readable information on the
* internal state of an Sample. It is used when streaming
* the Sample or for user information.
*/
String __repr__() const;
String __str__(const String & offset = "") const;
/** Description accessor */
void setDescription(const Description & description);
Description getDescription() const;
/** Dimension accessor */
UnsignedInteger getDimension() const;
/** Size accessor */
UnsignedInteger getSize() const;
/** Maximum accessor */
Point getMax() const;
/** Minimum accessor */
Point getMin() const;
/** Method add() appends an element to the collection */
void add(const Point & point);
/** Method add() appends another sample to the collection */
void add(const Sample & sample);
/** Stack the given sample to the current one */
void stack(const Sample & sample);
/**
* Method split() trunk the sample before the index passed as argument
* and returns the remainder as new sample. This method tries its best not for doubling
* memory usage.
*/
Sample split(const UnsignedInteger index);
/**
* Method computeMean() gives the mean of the sample, based on the formula
* mean = sum of the elements in the sample / size of the sample
*/
Point computeMean() const;
/**
* Method computeCovariance() gives the covariance of the sample
*/
CovarianceMatrix computeCovariance() const;
/**
* Method computeStandardDeviation() gives the standard deviation of the sample
*/
TriangularMatrix computeStandardDeviation() const;
/**
* Method computeVariance() gives the variance of the sample (by component)
*/
Point computeVariance() const;
/**
* Method computeStandardDeviationPerComponent() gives the standard deviation of each component of the sample
*/
Point computeStandardDeviationPerComponent() const;
/**
* Method computePearsonCorrelation() gives the Pearson correlation matrix of the sample
*/
CorrelationMatrix computeLinearCorrelation() const;
CorrelationMatrix computePearsonCorrelation() const;
/**
* Method computeSpearmanCorrelation() gives the Spearman correlation matrix of the sample
*/
CorrelationMatrix computeSpearmanCorrelation() const;
/**
* Gives the Kendall correlation matrix of the sample
*/
CorrelationMatrix computeKendallTau() const;
/**
* Method computeRange gives the range of the sample (by component)
*/
Point computeRange() const;
/**
* Method computeMedian() gives the median of the sample (by component)
*/
Point computeMedian() const;
/**
* Method computeSkewness() gives the skewness of the sample (by component)
*/
Point computeSkewness() const;
/**
* Method computeKurtosis() gives the kurtosis of the sample (by component)
*/
Point computeKurtosis() const;
/**
* Gives the centered moment of order k of the sample (by component)
*/
Point computeCenteredMoment(const UnsignedInteger k) const;
/**
* Gives the raw moment of order k of the sample (by component)
*/
Point computeRawMoment(const UnsignedInteger k) const;
/**
* Method computeQuantilePerComponent() gives the quantile per component of the sample
*/
Point computeQuantilePerComponent(const Scalar prob) const;
/**
* Method computeQuantile() gives the N-dimension quantile of the sample
*/
Point computeQuantile(const Scalar prob) const;
/**
* Get the empirical CDF of the sample
*/
Scalar computeEmpiricalCDF(const Point & point,
const Bool tail = false) const;
/**
* Get the position of a point in the sample.
* Returns size if the point does not belong to the sample.
*/
UnsignedInteger find(const Point & point) const;
/**
* Translate realizations in-place
*/
Sample & operator += (const Scalar translation);
Sample & operator += (const Point & translation);
Sample & operator += (const Sample & translation);
Sample & operator -= (const Scalar translation);
Sample & operator -= (const Point & translation);
Sample & operator -= (const Sample & translation);
/** Translate/scale realizations */
Sample operator + (const Scalar translation) const;
Sample operator + (const Point & translation) const;
Sample operator + (const Sample & translation) const;
Sample operator - (const Scalar translation) const;
Sample operator - (const Point & translation) const;
Sample operator - (const Sample & translation) const;
Sample operator * (const Scalar scaling) const;
Sample operator * (const Point & scaling) const;
Sample operator * (const SquareMatrix & scaling) const;
Sample operator / (const Scalar scaling) const;
Sample operator / (const Point & scaling) const;
Sample operator / (const SquareMatrix & scaling) const;
/**
* Scale realizations componentwise in-place
*/
Sample & operator *= (const Scalar scaling);
Sample & operator *= (const Point & scaling);
Sample & operator *= (const SquareMatrix & scaling);
Sample & operator /= (const Scalar scaling);
Sample & operator /= (const Point & scaling);
Sample & operator /= (const SquareMatrix & scaling);
/** Ranked sample */
Sample rank() const;
/** Ranked component */
Sample rank(const UnsignedInteger index) const;
/** Sorted sample */
Sample sort() const;
/** Sorted component */
Sample sort(const UnsignedInteger index) const;
/** Sorted according a component */
Sample sortAccordingToAComponent(const UnsignedInteger index) const;
/* Sorted and duplicated points removed */
Sample sortUnique() const;
/** Store a sample in a temporary text file, one realization by line. Returns the file name. */
virtual String storeToTemporaryFile() const;
/** Get the i-th marginal sample */
Sample getMarginal(const UnsignedInteger index) const;
/** Get the marginal sample corresponding to indices dimensions */
Sample getMarginal(const Indices & indices) const;
/** Returns a pointer to the underlying implementation object */
virtual ImplementationAsPersistentObject getImplementationAsPersistentObject() const;
/** Sets the pointer to the underlying implementation object */
virtual void setImplementationAsPersistentObject(const ImplementationAsPersistentObject & obj);
}; /* class Sample */
END_NAMESPACE_OPENTURNS
#endif /* OPENTURNS_SAMPLE_HXX */
|