/usr/share/pyshared/pymc/examples/gp/covparams.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 | from pymc.gp import *
from pymc.gp.cov_funs import *
from numpy import *
# Covariance
C = Covariance(eval_fun = matern.euclidean, diff_degree = 1.4, amp = 1., scale = 1.)
# C = Covariance(eval_fun = pow_exp.euclidean, pow=1., amp=1., scale=1.)
# C = Covariance(eval_fun = quadratic.euclidean, phi=1., amp=1., scale=.2)
# C = Covariance(eval_fun = gaussian.euclidean, amp=1., scale=1.)
# C = Covariance(eval_fun = sphere.euclidean, amp=1., scale=.5)
# Mean
def zero_fun(x):
return 0.*x
M = Mean(zero_fun)
#### - Plot - ####
if __name__ == '__main__':
from pylab import *
x=arange(-1.,1.,.01)
close('all')
figure()
# Plot the covariance function
subplot(2,2,1)
contourf(x,x,C(x,x).view(ndarray),origin='lower',extent=(-1.,1.,-1.,1.),cmap=cm.bone)
xlabel('x')
ylabel('y')
title('C(x,y)')
axis('tight')
colorbar()
# Plot a slice of the covariance function
subplot(2,2,2)
plot(x,C(x,0).view(ndarray).ravel(),'k-')
axis([-1,1,0,1])
xlabel('x')
ylabel('C(x,0)')
title('A slice of C')
subplot(2,1,2)
# plot_envelope(M, C, mesh=x)
for i in range(3):
f = Realization(M, C)
plot(x, f(x))
xlabel('x')
ylabel('f(x)')
title('Three realizations')
axis([-1,1,-2,2])
# show()
|