e_to_p {hyperdirichlet} | R Documentation |
Transform from a simplex (either regular or right-angled) to a hypercube.
e_to_p(e) p_to_e(p) Jacobian(e)
e |
Vector with all elements between 0 and 1 (hypercube) |
p |
Vector of positive elements whose sum is either equal to, or less than, one (simplex) |
Function e_to_p()
takes one from e
-space to
p
-space.
Function p_to_e()
takes one from p
-space to
e
-space. This is useful when integrating over a simplex; use
Jacobian()
to evaluate the Jacobian of the transform.
Forward transformation:
e_1=sum_{i=1}^d p_i
e_i=frac{p_{i-1}}{sum_{j=i-1}^d p_j}, 2 <= i <= d
Backward transformation:
p_1=e_1 e_2
p_i=e_1 e_{i+1} prod_{i=2}^{i}(1-e_i), 2 <= i <= d
Jacobian:
J=prod_{i=2}^{d-1}(1-e_i)^{d-i}
To do a regular simplex, use the “di” of the right-angled simplex; see the examples.
Robin K. S. Hankin
M. Evans and T. Swartz 2000. Approximating Integrals via Monte Carlo and Deterministic Methods, Oxford University Press; page 28
# First, try to calculate the volume of a 4-simplex: adapt(5,rep(0,5),rep(1,5),functn=function(x){Jacobian(c(1,x))}) # Should be close to 1/5! = 1/120 ~= 0.008333 # Now, try to calculate the volume of a triangular-based pyramid: adapt(3,rep(0,3),rep(1,3),functn=Jacobian) # Should be close to 1/8=0.125