/usr/share/pyshared/pymc/gp/cov_funs/nsmatern.py is in python-pymc 2.2+ds-1.
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 | from . import isotropic_cov_funs
import numpy as np
__all__ = ['nsmatern','nsmatern_diag','default_h']
def default_h(x):
return np.ones(x.shape[:-1])
def nsmatern(C,x,y,diff_degree,amp=1.,scale=1.,h=default_h,cmin=0,cmax=-1,symm=False):
"""
A covariance function. Remember, broadcasting for covariance functions works
differently than for numpy universal functions. C(x,y) returns a matrix, and
C(x) returns a vector.
:Parameters:
- `amp`: The pointwise standard deviation of f.
- `scale`: The factor by which to scale the distance between points.
Large value implies long-range correlation.
- `diff_degree`: A function that takes arrays and returns the degree
of differentiability at each location.
- `h`: A function that takes arrays and returns the relative amplitude
at each location.
- `x and y` are arrays of points in Euclidean coordinates
formatted as follows:
[[x_{0,0} ... x_{0,ndim}],
[x_{1,0} ... x_{1,ndim}],
...
[x_{N,0} ... x_{N,ndim}]]
- `symm` indicates whether x and y are references to
the same array.
- `cmin' and `cmax' indicate which columns to compute.
These are used for multithreaded evaluation.
:Reference: Pintore and Holmes, 2010, "Spatially adaptive non-stationary covariance functions
via spatially adaptive spectra". Journal of the American Statistical Association.
Forthcoming.
"""
ddx, ddy = diff_degree(x), diff_degree(y)
hx, hy = h(x), h(y)
# for rkbesl
nmax = np.floor(max(np.max(ddx), np.max(ddy)))
# Compute covariance for this bit
isotropic_cov_funs.nsmatrn(C,ddx,ddy,hx,hy,nmax,cmin,cmax,symm=symm)
return C
def nsmatern_diag(x,diff_degree, amp=1., scale=1.,h=default_h):
return (h(x)*amp)**2
|