This is a file from the Wikimedia Commons

File:Gaussian process 2D squared exp.png

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Gaussian_process_2D_squared_exp.png(648 × 325 pixels, file size: 69 KB, MIME type: image/png)

Summary

Description
English: Random sample from 2D gaussian process with squared exponetial radial covariance function.
Date
Source Own work
Author Physikinger
PNG development
InfoField
 
This plot was created with Matplotlib.
Source code
InfoField

Python code

# This source code is public domain 
# Author: Christian Schirm
import numpy
import matplotlib.pyplot as plt

# To speed up the random generation, a numerical trick 
# is used based on the fast fourier transform. See e.g.
# D. P. Kroese et al., "Spatial Process Generation", 2013
# https://arxiv.org/pdf/1308.0399.pdf

n = 2**8
x = numpy.arange(-n/2,n/2)/float(n)
def covFunc(r): return numpy.exp(-r**2)
def cov(deltaX, deltaY): return covFunc(8*(deltaX**2 + deltaY**2)**0.5)
indX,indY = numpy.mgrid[0:n,0:n]
C = cov(x[indX],x[indY])
Gamma = numpy.fft.fft2(numpy.roll(numpy.roll(C,len(C)/2,0),len(C)/2,1))
Z1 = numpy.random.randn(n,n) + 1J*numpy.random.randn(n,n)
X = numpy.fft.fft2(numpy.sqrt(Gamma) *Z1/n).real

fig, (plt2, plt1) = plt.subplots(nrows=1, ncols=2, figsize=(10./1.7, 4.5/1.7), dpi=120)
plt1.imshow(X,cmap='viridis',vmin=-2.5,vmax=2.5,extent=[0,10,0,10])
xCov = numpy.linspace(0,0.825,100)
plt2.plot(8*xCov, covFunc(8*xCov), label='exp(-r$^2$)')
plt2.set_xlabel('r')
plt2.set_ylabel('Covariance')
plt2.axis([0,5,0,1])
plt2.legend()
plt.savefig('Gaussian_process_2D_squared_exp.png')

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

22 August 2017

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current22:21, 22 August 2017Thumbnail for version as of 22:21, 22 August 2017648 × 325 (69 KB)Physikingerfont size
21:58, 22 August 2017Thumbnail for version as of 21:58, 22 August 2017820 × 408 (82 KB)PhysikingerUser created page with UploadWizard

The following page uses this file:

Global file usage

The following other wikis use this file:

Metadata