dwavefunction: Wave Function Density

Description Usage Arguments Details Value See Also Examples

View source: R/wavefunction.R

Description

Evaluate the density of a wave function model

Usage

1
dwavefunction(x, w, log = FALSE, amplitude = FALSE)

Arguments

x

a numeric vector

w

a vector of coefficients from wavefunction_fit

log

if TRUE, returns the log density instead of the density

amplitude

if TRUE, returns the amplitude (or the log of the absolute value of the amplitude) instead of the density. The density is the squared amplitude, but the amplitude may be positive or negative.

Details

The elements of the returned vector p are (when log and amplitude are FALSE):

p[i] = (w[1] H[0](x) / e[1] + ... + w[K+1] H[k](x) / e[K+1])^2 * exp(-x^2) where e[k] = sqrt(sqrt(pi) * 2^k * k!)

Here, K is the maximum degree, equal to length(w)-1, and H[k] is the Hermite polynomial of degree k. Note that w, being an R vector, is one-indexed, so w[k] is associated with the Hermite polynomial of degree k-1.

Value

a numeric vector of the same length as x

See Also

Madeleine B. Thompson, “Wave function representation of probability distributions,” 2017, https://arxiv.org/abs/1712.07764.

Examples

1
2
3
  x <- rnorm(100)
  w <- wavefunction_fit(x, degree = 6)
  p <- dwavefunction(x, w)

wavefunction documentation built on May 2, 2019, 7:04 a.m.