-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGaussianFieldRealization2D.jl
35 lines (28 loc) · 1.3 KB
/
GaussianFieldRealization2D.jl
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
"""
visualize a realization of a 2D random field
created: April 2020
author©: Alois Pichler
"""
using Gnuplot; Gnuplot.options.gpviewer= true; # external viewer
include("KernelsRKHS.jl")
function Kernel(x, y)
MaternKernel(x,y; ℓ= .1, ν= 1.5)
# GaussKernel(x,y; ℓ= .1)
# SigmoidKernel(x,y; ℓ= .1)
end
# │ test plots
# ╰────────────────────────────────────────────────────
println("───────────── ", time())
x= range(0, stop= 1, length= 100)
y= range(0, stop= 1, length= 101)
f2DRKHS=RKHS([[x,y] for y in y for x in x], kernel= Kernel) # new realization
@gp "set terminal wxt 0; reset; set title 'Gaussian random field'"
field= rand(MvNormal(0.0001I+ Gram([[x,y] for y in y for x in x], Kernel)))
@gsp :- "set size square" "set auto fix" :-
#@gsp :- "unset xtics" "unset ytics" "unset ztics" "unset border" :-
@gsp :- x y reshape(field, length(x), :) "w pm3d title 'Random field'"
@gsp "set terminal windows 0 title 'function'" "reset" :- # or wxt
@gsp :- "set title 'RKHS function'; set xlabel 'x'; set ylabel 'y'" :-
#@gsp :- "unset xtics; unset ytics; unset ztics; unset border" :-
@gsp :- x y reshape(f2DRKHS.([[x,y] for y in y for x in x]), length(x), :) "w pm3d title ''"
time()