## Settings for RMarkdown http://yihui.name/knitr/options#chunk_options
opts_chunk$set(comment = "", warning = FALSE, message = FALSE, tidy = FALSE,
echo = TRUE, fig.width = 7, fig.height = 7)
options(width = 116, scipen = 10)
setwd("~/statistics/Rmedstats/")
\(f(x,y) = a * exp(- \frac {(x^2 + y^2)} {b})\)
##
f.2d.gaussian <- function(a, b, x, y) {
a * exp(-(x^2 + y^2) / b)
}
axis.vector <- seq(from = -3, to = 3, by = 0.1)
Constants: a = 1, b = 1
z.axis.vector <- outer(X = axis.vector, Y = axis.vector, function(X,Y) f.2d.gaussian(a = 1, b = 1, x = X, y = Y))
persp(x = axis.vector,
y = axis.vector,
z = z.axis.vector,
theta = 30, phi = 30, expand = 0.6, shade = 0.3)
http://sugakuart.com/products09.html
\(f(x,y) = a * exp(- \frac {{(x - y)}^2} {b})\)
f.sugakuart.com <- function(a, b, x, y) {
a * exp(- (x - y)^2 / b)
}
z.axis.vector.2 <- outer(X = axis.vector, Y = axis.vector, function(X,Y) f.sugakuart.com(a = 1, b = 1, x = X, y = Y))
persp(x = axis.vector,
y = axis.vector,
z = z.axis.vector.2,
theta = 120, phi = 15, expand = 0.6, shade = 0.3)
From different angles
layout(matrix(1:9, ncol = 3, byrow = T))
par(mar = c(0,0,0,0))
for(i in seq(0, 360, length.out = 9)) {
persp(x = axis.vector,
y = axis.vector,
z = z.axis.vector.2,
theta = i, phi = 15, expand = 0.6, shade = 0.3)
}