LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
|
Stores values of a function sampled on an image and allows you to interpolate the function to unsampled points. More...
#include <GaussianProcess.h>
Public Member Functions | |
GaussianProcess (const GaussianProcess &)=delete | |
GaussianProcess & | operator= (const GaussianProcess &)=delete |
GaussianProcess (GaussianProcess &&)=delete | |
GaussianProcess & | operator= (GaussianProcess &&)=delete |
GaussianProcess (ndarray::Array< T, 2, 2 > const &dataIn, ndarray::Array< T, 1, 1 > const &ff, std::shared_ptr< Covariogram< T > > const &covarIn) | |
This is the constructor you call if you do not wish to normalize the positions of your data points and you have only one function. | |
GaussianProcess (ndarray::Array< T, 2, 2 > const &dataIn, ndarray::Array< T, 1, 1 > const &mn, ndarray::Array< T, 1, 1 > const &mx, ndarray::Array< T, 1, 1 > const &ff, std::shared_ptr< Covariogram< T > > const &covarIn) | |
This is the constructor you call if you want the positions of your data points normalized by the span of each dimension and you have only one function. | |
GaussianProcess (ndarray::Array< T, 2, 2 > const &dataIn, ndarray::Array< T, 2, 2 > const &ff, std::shared_ptr< Covariogram< T > > const &covarIn) | |
this is the constructor to use in the case of a vector of input functions and an unbounded/unnormalized parameter space | |
GaussianProcess (ndarray::Array< T, 2, 2 > const &dataIn, ndarray::Array< T, 1, 1 > const &mn, ndarray::Array< T, 1, 1 > const &mx, ndarray::Array< T, 2, 2 > const &ff, std::shared_ptr< Covariogram< T > > const &covarIn) | |
this is the constructor to use in the case of a vector of input functions using minima and maxima in parameter space | |
int | getNPoints () const |
return the number of data points stored in the GaussianProcess | |
int | getDim () const |
return the dimensionality of data points stored in the GaussianProcess | |
void | getData (ndarray::Array< T, 2, 2 > pts, ndarray::Array< T, 1, 1 > fn, ndarray::Array< int, 1, 1 > indices) const |
Return a sub-sample the data underlying the Gaussian Process. | |
void | getData (ndarray::Array< T, 2, 2 > pts, ndarray::Array< T, 2, 2 > fn, ndarray::Array< int, 1, 1 > indices) const |
Return a sub-sample the data underlying the Gaussian Process. | |
T | interpolate (ndarray::Array< T, 1, 1 > variance, ndarray::Array< T, 1, 1 > const &vin, int numberOfNeighbors) const |
Interpolate the function value at one point using a specified number of nearest neighbors. | |
void | interpolate (ndarray::Array< T, 1, 1 > mu, ndarray::Array< T, 1, 1 > variance, ndarray::Array< T, 1, 1 > const &vin, int numberOfNeighbors) const |
This is the version of GaussianProcess::interpolate for a vector of functions. | |
T | selfInterpolate (ndarray::Array< T, 1, 1 > variance, int dex, int numberOfNeighbors) const |
This method will interpolate the function on a data point for purposes of optimizing hyper parameters. | |
void | selfInterpolate (ndarray::Array< T, 1, 1 > mu, ndarray::Array< T, 1, 1 > variance, int dex, int numberOfNeighbors) const |
The version of selfInterpolate called for a vector of functions. | |
void | batchInterpolate (ndarray::Array< T, 1, 1 > mu, ndarray::Array< T, 1, 1 > variance, ndarray::Array< T, 2, 2 > const &queries) const |
Interpolate a list of query points using all of the input data (rather than nearest neighbors) | |
void | batchInterpolate (ndarray::Array< T, 1, 1 > mu, ndarray::Array< T, 2, 2 > const &queries) const |
Interpolate a list of points using all of the data. | |
void | batchInterpolate (ndarray::Array< T, 2, 2 > mu, ndarray::Array< T, 2, 2 > variance, ndarray::Array< T, 2, 2 > const &queries) const |
This is the version of batchInterpolate (with variances) that is called for a vector of functions. | |
void | batchInterpolate (ndarray::Array< T, 2, 2 > mu, ndarray::Array< T, 2, 2 > const &queries) const |
This is the version of batchInterpolate (without variances) that is called for a vector of functions. | |
void | addPoint (ndarray::Array< T, 1, 1 > const &vin, T f) |
Add a point to the pool of data used by GaussianProcess for interpolation. | |
void | addPoint (ndarray::Array< T, 1, 1 > const &vin, ndarray::Array< T, 1, 1 > const &f) |
This is the version of addPoint that is called for a vector of functions. | |
void | removePoint (int dex) |
This will remove a point from the data set. | |
void | setKrigingParameter (T kk) |
Assign a value to the Kriging paramter. | |
void | setCovariogram (std::shared_ptr< Covariogram< T > > const &covar) |
Assign a different covariogram to this GaussianProcess. | |
void | setLambda (T lambda) |
set the value of the hyperparameter _lambda | |
GaussianProcessTimer & | getTimes () const |
Give the user acces to _timer, an object keeping track of the time spent on various processes within interpolate. | |
Stores values of a function sampled on an image and allows you to interpolate the function to unsampled points.
The data will be stored in a KD Tree for easy nearest neighbor searching when interpolating.
The array _function[] will contain the values of the function being interpolated. You can provide a two dimensional array _function[][] if you wish to interpolate a vector of functions. In this case _function[i][j] is the jth function associated with the ith data point. Note: presently, the covariance matrices do not relate elements of _function[i][] to each other, so the variances returned will be identical for all functions evaluated at the same point in parameter space.
_data[i][j] will be the jth component of the ith data point.
_max and _min contain the maximum and minimum values of each dimension in parameter space (if applicable) so that data points can be normalized by _max-_min to keep distances between points reasonable. This is an option specified by calling the relevant constructor.
Definition at line 471 of file GaussianProcess.h.
|
delete |
|
delete |
lsst::afw::math::GaussianProcess< T >::GaussianProcess | ( | ndarray::Array< T, 2, 2 > const & | dataIn, |
ndarray::Array< T, 1, 1 > const & | ff, | ||
std::shared_ptr< Covariogram< T > > const & | covarIn ) |
This is the constructor you call if you do not wish to normalize the positions of your data points and you have only one function.
[in] | dataIn | an ndarray containing the data points; the ith row of datain is the ith data point |
[in] | ff | a one-dimensional ndarray containing the values of the scalar function associated with each data point. This is the function you are interpolating |
[in] | covarIn | is the input covariogram |
Definition at line 751 of file GaussianProcess.cc.
lsst::afw::math::GaussianProcess< T >::GaussianProcess | ( | ndarray::Array< T, 2, 2 > const & | dataIn, |
ndarray::Array< T, 1, 1 > const & | mn, | ||
ndarray::Array< T, 1, 1 > const & | mx, | ||
ndarray::Array< T, 1, 1 > const & | ff, | ||
std::shared_ptr< Covariogram< T > > const & | covarIn ) |
This is the constructor you call if you want the positions of your data points normalized by the span of each dimension and you have only one function.
[in] | dataIn | an ndarray containing the data points; the ith row of datain is the ith data point |
[in] | mn | a one-dimensional ndarray containing the minimum values of each dimension (for normalizing the positions of data points) |
[in] | mx | a one-dimensional ndarray containing the maximum values of each dimension (for normalizing the positions of data points) |
[in] | ff | a one-dimensional ndarray containing the values of the scalar function associated with each data point. This is the function you are interpolating |
[in] | covarIn | is the input covariogram |
Note: the member variable _useMaxMin will allow the code to remember which constructor you invoked
Definition at line 786 of file GaussianProcess.cc.
lsst::afw::math::GaussianProcess< T >::GaussianProcess | ( | ndarray::Array< T, 2, 2 > const & | dataIn, |
ndarray::Array< T, 2, 2 > const & | ff, | ||
std::shared_ptr< Covariogram< T > > const & | covarIn ) |
this is the constructor to use in the case of a vector of input functions and an unbounded/unnormalized parameter space
[in] | dataIn | contains the data points, as in other constructors |
[in] | ff | contains the functions. Each row of ff corresponds to a datapoint. Each column corresponds to a function (ff[i][j] is the jth function associated with the ith data point) |
[in] | covarIn | is the input covariogram |
Definition at line 837 of file GaussianProcess.cc.
lsst::afw::math::GaussianProcess< T >::GaussianProcess | ( | ndarray::Array< T, 2, 2 > const & | dataIn, |
ndarray::Array< T, 1, 1 > const & | mn, | ||
ndarray::Array< T, 1, 1 > const & | mx, | ||
ndarray::Array< T, 2, 2 > const & | ff, | ||
std::shared_ptr< Covariogram< T > > const & | covarIn ) |
this is the constructor to use in the case of a vector of input functions using minima and maxima in parameter space
[in] | dataIn | contains the data points, as in other constructors |
[in] | mn | contains the minimum allowed values of the parameters in parameter space |
[in] | mx | contains the maximum allowed values of the parameters in parameter space |
[in] | ff | contains the functions. Each row of ff corresponds to a datapoint. Each column corresponds to a function (ff[i][j] is the jth function associated with the ith data point) |
[in] | covarIn | is the input covariogram |
Definition at line 868 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::addPoint | ( | ndarray::Array< T, 1, 1 > const & | vin, |
ndarray::Array< T, 1, 1 > const & | f ) |
This is the version of addPoint that is called for a vector of functions.
pex::exceptions::RuntimeError | if the tree does not end up properly constructed (the exception is actually thrown by KdTree<T>::addPoint() ) |
Note: excessive use of addPoint and removePoint can result in an unbalanced KdTree, which will slow down nearest neighbor searches
Definition at line 1907 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::addPoint | ( | ndarray::Array< T, 1, 1 > const & | vin, |
T | f ) |
Add a point to the pool of data used by GaussianProcess for interpolation.
[in] | vin | a one-dimensional ndarray storing the point in parameter space that you are adding |
[in] | f | the value of the function at that point |
pex::exceptions::RuntimeError | if you call this when you should have called the version taking a vector of functions (below) |
pex::exceptions::RuntimeError | if the tree does not end up properly constructed (the exception is actually thrown by KdTree<T>::addPoint() ) |
Note: excessive use of addPoint and removePoint can result in an unbalanced KdTree, which will slow down nearest neighbor searches
Definition at line 1862 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::batchInterpolate | ( | ndarray::Array< T, 1, 1 > | mu, |
ndarray::Array< T, 1, 1 > | variance, | ||
ndarray::Array< T, 2, 2 > const & | queries ) const |
Interpolate a list of query points using all of the input data (rather than nearest neighbors)
[out] | mu | a 1-dimensional ndarray where the interpolated function values will be stored |
[out] | variance | a 1-dimensional ndarray where the corresponding variances in the function value will be stored |
[in] | queries | a 2-dimensional ndarray containing the points to be interpolated. queries[i][j] is the jth component of the ith point |
This method will attempt to construct a _npts X _npts covariance matrix C and solve the problem Cx=b. Be wary of using it in the case where _npts is very large.
This version of the method will also return variances for all of the query points. That is a very time consuming calculation relative to just returning estimates for the function. Consider calling the version of this method that does not calculate variances (below). The difference in time spent is an order of magnitude for 189 data points and 1,000,000 interpolations.
Definition at line 1488 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::batchInterpolate | ( | ndarray::Array< T, 1, 1 > | mu, |
ndarray::Array< T, 2, 2 > const & | queries ) const |
Interpolate a list of points using all of the data.
Do not return variances for the interpolation.
[out] | mu | a 1-dimensional ndarray where the interpolated function values will be stored |
[in] | queries | a 2-dimensional ndarray containing the points to be interpolated. queries[i][j] is the jth component of the ith point |
This method will attempt to construct a _npts X _npts covariance matrix C and solve the problem Cx=b. Be wary of using it in the case where _npts is very large.
This version of the method does not return variances. It is an order of magnitude faster than the version of the method that does return variances (timing done on a case with 189 data points and 1 million query points).
Definition at line 1696 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::batchInterpolate | ( | ndarray::Array< T, 2, 2 > | mu, |
ndarray::Array< T, 2, 2 > const & | queries ) const |
This is the version of batchInterpolate (without variances) that is called for a vector of functions.
Definition at line 1775 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::batchInterpolate | ( | ndarray::Array< T, 2, 2 > | mu, |
ndarray::Array< T, 2, 2 > | variance, | ||
ndarray::Array< T, 2, 2 > const & | queries ) const |
This is the version of batchInterpolate (with variances) that is called for a vector of functions.
Definition at line 1588 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::getData | ( | ndarray::Array< T, 2, 2 > | pts, |
ndarray::Array< T, 1, 1 > | fn, | ||
ndarray::Array< int, 1, 1 > | indices ) const |
Return a sub-sample the data underlying the Gaussian Process.
[out] | pts | will contain the data points from the Gaussian Process |
[out] | fn | will contain the function values from the Gaussian Process |
[in] | indices | is an array of indices indicating the points to return |
Definition at line 929 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::getData | ( | ndarray::Array< T, 2, 2 > | pts, |
ndarray::Array< T, 2, 2 > | fn, | ||
ndarray::Array< int, 1, 1 > | indices ) const |
Return a sub-sample the data underlying the Gaussian Process.
[out] | pts | will contain the data points from the Gaussian Process |
[out] | fn | will contain the function values from the Gaussian Process |
[in] | indices | is an array of indices indicating the points to return |
Definition at line 968 of file GaussianProcess.cc.
int lsst::afw::math::GaussianProcess< T >::getDim | ( | ) | const |
return the dimensionality of data points stored in the GaussianProcess
Definition at line 924 of file GaussianProcess.cc.
int lsst::afw::math::GaussianProcess< T >::getNPoints | ( | ) | const |
return the number of data points stored in the GaussianProcess
Definition at line 919 of file GaussianProcess.cc.
GaussianProcessTimer & lsst::afw::math::GaussianProcess< T >::getTimes | ( | ) | const |
Give the user acces to _timer, an object keeping track of the time spent on various processes within interpolate.
This will return a GaussianProcessTimer object. The user can, for example, see how much time has been spent on Eigen's linear algebra package (see the comments on the GaussianProcessTimer class) using code like
gg=GaussianProcess(....)
ticktock=gg.getTimes()
ticktock.display()
Definition at line 1981 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::interpolate | ( | ndarray::Array< T, 1, 1 > | mu, |
ndarray::Array< T, 1, 1 > | variance, | ||
ndarray::Array< T, 1, 1 > const & | vin, | ||
int | numberOfNeighbors ) const |
This is the version of GaussianProcess::interpolate for a vector of functions.
[out] | mu | will store the vector of interpolated function values |
[out] | variance | will store the vector of interpolated variances on mu |
[in] | vin | the point at which you wish to interpolate the functions |
[in] | numberOfNeighbors | is the number of nearest neighbor points to use in the interpolation |
Note: Because the variance currently only depends on the covariance function and the covariance function currently does not include any terms relating different elements of mu to each other, all of the elements of variance will be identical
Definition at line 1131 of file GaussianProcess.cc.
T lsst::afw::math::GaussianProcess< T >::interpolate | ( | ndarray::Array< T, 1, 1 > | variance, |
ndarray::Array< T, 1, 1 > const & | vin, | ||
int | numberOfNeighbors ) const |
Interpolate the function value at one point using a specified number of nearest neighbors.
[out] | variance | a one-dimensional ndarray. The value of the variance predicted by the Gaussian process will be stored in the zeroth element |
[in] | vin | a one-dimensional ndarray representing the point at which you want to interpolate the function |
[in] | numberOfNeighbors | the number of nearest neighbors to be used in the interpolation |
the interpolated value of the function will be returned at the end of this method
Note: if you used a normalized parameter space, you should not normalize vin before inputting. The code will remember that you want a normalized parameter space, and will apply the normalization when you call interpolate
Definition at line 1009 of file GaussianProcess.cc.
|
delete |
|
delete |
void lsst::afw::math::GaussianProcess< T >::removePoint | ( | int | dex | ) |
This will remove a point from the data set.
[in] | dex | the index of the point you want to remove from your data set |
pex::exceptions::RuntimeError | if the tree does not end up properly constructed (the exception is actually thrown by KdTree<T>::removePoint() ) |
Note: excessive use of addPoint and removePoint can result in an unbalanced KdTree, which will slow down nearest neighbor searches
Definition at line 1952 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::selfInterpolate | ( | ndarray::Array< T, 1, 1 > | mu, |
ndarray::Array< T, 1, 1 > | variance, | ||
int | dex, | ||
int | numberOfNeighbors ) const |
The version of selfInterpolate called for a vector of functions.
[out] | mu | this is where the interpolated function values will be stored |
[out] | variance | the variance on mu will be stored here |
[in] | dex | the index of the point you wish to interpolate |
[in] | numberOfNeighbors | the number of nearest neighbors to use in the interpolation |
pex::exceptions::RuntimeError | if the nearest neighbor search does not find the data point itself as the nearest neighbor |
Definition at line 1367 of file GaussianProcess.cc.
T lsst::afw::math::GaussianProcess< T >::selfInterpolate | ( | ndarray::Array< T, 1, 1 > | variance, |
int | dex, | ||
int | numberOfNeighbors ) const |
This method will interpolate the function on a data point for purposes of optimizing hyper parameters.
[out] | variance | a one-dimensional ndarray. The value of the variance predicted by the Gaussian process will be stored in the zeroth element |
[in] | dex | the index of the point you wish to self interpolate |
[in] | numberOfNeighbors | the number of nearest neighbors to be used in the interpolation |
pex::exceptions::RuntimeError | if the nearest neighbor search does not find the data point itself as the nearest neighbor |
The interpolated value of the function will be returned at the end of this method
This method ignores the point on which you are interpolating when requesting nearest neighbors
Definition at line 1244 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::setCovariogram | ( | std::shared_ptr< Covariogram< T > > const & | covar | ) |
Assign a different covariogram to this GaussianProcess.
[in] | covar | the Covariogram object that you wish to assign |
Definition at line 1971 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::setKrigingParameter | ( | T | kk | ) |
Assign a value to the Kriging paramter.
[in] | kk | the value assigned to the Kriging parameters |
Definition at line 1966 of file GaussianProcess.cc.
void lsst::afw::math::GaussianProcess< T >::setLambda | ( | T | lambda | ) |
set the value of the hyperparameter _lambda
[in] | lambda | the value you want assigned to _lambda |
_lambda is a parameter meant to represent the characteristic variance of the function you are interpolating. Currently, it is a scalar such that all data points must have the same characteristic variance. Future iterations of the code may want to promote _lambda to an array so that different data points can have different variances.
Definition at line 1976 of file GaussianProcess.cc.