The elements of the returned vector \(p\) are (when log and
amplitude are FALSE):
$$
p_i = \left(\sum_{k=0}^K \frac{w_{k+1}}{(\sqrt{\pi}2^k k!)^{1/2}} H_k(x_i) \right)^2 e^{-x_i^2}
$$
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\).