26 #ifndef LSST_AFW_MATH_GAUSSIAN_PROCESS_H
27 #define LSST_AFW_MATH_GAUSSIAN_PROCESS_H
29 #include <Eigen/Dense>
32 #include "ndarray/eigen.h"
130 template <
typename T>
158 virtual T
operator() (ndarray::Array<const T,1,1>
const &p1,
159 ndarray::Array<const T,1,1>
const &p2
173 template <
typename T>
187 virtual T
operator() (ndarray::Array<const T,1,1>
const &,
188 ndarray::Array<const T,1,1>
const &
208 template <
typename T>
226 virtual T
operator() (ndarray::Array<const T,1,1>
const &,
227 ndarray::Array<const T,1,1>
const &
246 template <
typename T>
271 void Initialize(ndarray::Array<T,2,2>
const &dt);
289 ndarray::Array<double,1,1> dd,
290 ndarray::Array<const T,1,1>
const &v,
301 T
getData(
int ipt,
int idim)
const;
325 ndarray::Array<T,1,1>
getData(
int ipt)
const;
334 void addPoint(ndarray::Array<const T,1,1>
const &v);
358 void getTreeNode(ndarray::Array<int,1,1>
const &v,
int dex)
const;
404 void _organize(ndarray::Array<int,1,1>
const &use,
414 int _findNode(ndarray::Array<const T,1,1>
const &v)
const;
466 void _count(
int where,
int *ct)
const;
485 double _distance(ndarray::Array<const T,1,1>
const &p1,
486 ndarray::Array<const T,1,1>
const &p2)
const;
513 template <
typename T>
541 ndarray::Array<T,1,1>
const &ff,
564 ndarray::Array<T,1,1>
const &mn,
565 ndarray::Array<T,1,1>
const &mx,
566 ndarray::Array<T,1,1>
const &ff,
581 ndarray::Array<T,2,2>
const &ff,
600 ndarray::Array<T,1,1>
const &mn,
601 ndarray::Array<T,1,1>
const &mx,
602 ndarray::Array<T,2,2>
const &ff,
623 ndarray::Array<T,1,1>
const &vin,
624 int numberOfNeighbors)
const;
641 ndarray::Array<T,1,1> variance,
642 ndarray::Array<T,1,1>
const &vin,
643 int numberOfNeighbors)
const;
666 int numberOfNeighbors)
const;
683 ndarray::Array<T,1,1> variance,
685 int numberOfNeighbors)
const;
709 ndarray::Array<T,1,1> variance,
710 ndarray::Array<T,2,2>
const &queries)
const;
730 ndarray::Array<T,2,2>
const &queries)
const;
737 ndarray::Array<T,2,2> variance,
738 ndarray::Array<T,2,2>
const &queries)
const;
745 ndarray::Array<T,2,2>
const &queries)
const;
764 void addPoint(ndarray::Array<T,1,1>
const &vin,T f);
775 void addPoint(ndarray::Array<T,1,1>
const &vin,ndarray::Array<T,1,1>
const &f);
855 #endif //#ifndef LSST_AFW_MATH_GAUSSIAN_PROCESS_H
void setCovariogram(std::shared_ptr< Covariogram< T > > const &covar)
Assign a different covariogram to this GaussianProcess.
GaussianProcess(const GaussianProcess &)=delete
ndarray::Array< double, 1, 1 > _neighborDistances
int _findNode(ndarray::Array< const T, 1, 1 > const &v) const
Find the point already in the tree that would be the parent of a point not in the tree...
void setSigma1(double sigma1)
set the _sigma1 hyper parameter
void addPoint(ndarray::Array< const T, 1, 1 > const &v)
Add a point to the tree. Allot more space in _tree and data if needed.
ndarray::Array< int, 1, 1 > _neighborCandidates
T getData(int ipt, int idim) const
Return one element of one node on the tree.
void setSigma0(double sigma0)
set the _sigma0 hyper parameter
void _organize(ndarray::Array< int, 1, 1 > const &use, int ct, int parent, int dir)
Find the daughter point of a node in the tree and segregate the points around it. ...
Stores values of a function sampled on an image and allows you to interpolate the function to unsampl...
void addToTotal(int i)
Adds time to _totalTime and adds counts to _interpolationCount.
This is a structure for keeping track of how long the interpolation methods spend on different parts ...
ndarray::Array< T, 1, 1 > _min
void _lookForNeighbors(ndarray::Array< const T, 1, 1 > const &v, int consider, int from) const
This method actually looks for the neighbors, determining whether or not to descend branches of the t...
void findNeighbors(ndarray::Array< int, 1, 1 > neighdex, ndarray::Array< double, 1, 1 > dd, ndarray::Array< const T, 1, 1 > const &v, int n_nn) const
Find the nearest neighbors of a point.
The parent class of covariogram functions for use in Gaussian Process interpolation.
ndarray::Array< int, 2, 2 > _tree
void setKrigingParameter(T kk)
Assign a value to the Kriging paramter.
double _distance(ndarray::Array< const T, 1, 1 > const &p1, ndarray::Array< const T, 1, 1 > const &p2) const
calculate the Euclidean distance between the points p1 and p2
void start()
Starts the timer for an individual call to an interpolation routine.
void _count(int where, int *ct) const
A method which counts the number of nodes descended from a given node (used by removePoint(int)) ...
void addToVariance()
Adds time to _varianceTime.
void setLambda(T lambda)
set the value of the hyperparameter _lambda
ndarray::Array< T, 2, 2 > _function
Covariogram & operator=(const Covariogram &)=delete
void Initialize(ndarray::Array< T, 2, 2 > const &dt)
Build a KD Tree to store the data for 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...
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) ...
ndarray::Array< T, 1, 1 > _max
void addToIteration()
Adds time to _iterationTime.
std::shared_ptr< Covariogram< T > > _covariogram
The data for GaussianProcess is stored in a KD tree to facilitate nearest-neighbor searches...
a Covariogram that falls off as the negative exponent of the square of the distance between the point...
void _descend(int root)
Descend the tree from a node which has been removed, reassigning severed nodes as you go...
a Covariogram that recreates a neural network with one hidden layer and infinite units in that layer ...
GaussianProcessTimer & getTimes() const
Give the user acces to _timer, an object keeping track of the time spent on various processes within ...
Interface for DateTime class.
Covariogram()
construct a Covariogram assigning default values to the hyper parameters
Citizen(const std::type_info &)
afw::table::Key< double > sigma1
void removePoint(int dex)
Remove a point from the tree. Reorganize what remains so that the tree remains self-consistent.
virtual ~SquaredExpCovariogram()
void getTreeNode(ndarray::Array< int, 1, 1 > const &v, int dex) const
Return the _tree information for a given data point.
ndarray::Array< int, 1, 1 > _inn
virtual T operator()(ndarray::Array< const T, 1, 1 > const &, ndarray::Array< const T, 1, 1 > const &) const
Actually evaluate the covariogram function relating two points you want to interpolate from...
GaussianProcessTimer _timer
void addToSearch()
Adds time to _searchTime.
int _walkUpTree(int target, int dir, int root) const
A method to make sure that every data point in the tree is in the correct position relative to its pa...
void removePoint(int dex)
This will remove a point from the data set.
int _testTree() const
Make sure that the tree is properly constructed. Returns 1 of it is. Return zero if not...
ndarray::Array< T, 2, 2 > _data
virtual T operator()(ndarray::Array< const T, 1, 1 > const &, ndarray::Array< const T, 1, 1 > const &) const
Actually evaluate the covariogram function relating two points you want to interpolate from...
KdTree & operator=(const KdTree &)=delete
virtual T operator()(ndarray::Array< const T, 1, 1 > const &p1, ndarray::Array< const T, 1, 1 > const &p2) const
Actually evaluate the covariogram function relating two points you want to interpolate from...
void addPoint(ndarray::Array< T, 1, 1 > const &vin, T f)
Add a point to the pool of data used by GaussianProcess for interpolation.
GaussianProcess & operator=(const GaussianProcess &)=delete
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Include files required for standard LSST Exception handling.
int getPoints() const
return the number of data points stored in the tree
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.
virtual ~NeuralNetCovariogram()
void setEllSquared(double ellSquared)
set the _ellSquared hyper parameter (the square of the characteristic length scale of the covariogram...
void display()
Displays the current values of all times and _interpolationCount.
void _reassign(int target)
Reassign nodes to the tree that were severed by a call to removePoint(int)
void reset()
Resets all of the data members of GaussianProcessTimer to zero.
void addToEigen()
Adds time to _eigenTime.