The plasma effect: correction
Posted on February 11, 2023
by Stéphane Laurent
There’s a kind of error in the previous post. In this formula: \[ \exp\Bigl(-\frac{{(i/n-0.5)}^2 + {(j/n-0.5)}^2}{0.025^2} \Bigr), \] the indices \(i\) and \(j\) should range from \(0\) to \(n\), and \(n\) must be even in order to get something centered. See the corrected code for details:
function(n = 400L, gaussianMean = -50, gaussianSD = 5) {
fplasma4 <- n + 1L
n <- matrix(
M <-rnorm(n*n, gaussianMean, gaussianSD),
nrow = n, ncol = n
) dft(M)
FT <- n - 1L
n <-for(i in seq(n+1L)) {
for(j in seq(n+1L)) {
FT[i, j] *
FT[i, j] <- exp(-(((i-1L)/n - 0.5)^2 + ((j-1L)/n - 0.5)^2) / 0.025^2)
}
} dft(FT, inverse = TRUE)
IFT <-colorMap1(IFT, reverse = c(FALSE, FALSE, TRUE))
}
The funny point is that the result is more interesting with the “error”. But it is not bad without it: