MyNixOS website logo
Description

Symbolic Central and Noncentral Moments of the Multivariate Normal Distribution.

Symbolic central and non-central moments of the multivariate normal distribution. Computes a standard representation, LateX code, and values at specified mean and covariance matrices.

symmoments

R-CMD-check

Symbolically computes and numerically evaluates multivariate normal moments , where , in terms of mu and S elements.

Installation

You can install the development version of symmoments from GitHub with:

# install.packages("pak")
pak::pak("FloSchuberth/symmoments")

Example

This is a basic example which shows you how to solve a common problem:

library(symmoments)
 # Compute the moment for the 4-dimensional moment c(1,2,3,4):
callmultmoments(c(1,2,3,4))
#> E[ X1^1 X2^2 X3^3 X4^4 ]: 
#>    coef S(1,1) S(1,2) S(1,3) S(1,4) S(2,2) S(2,3) S(2,4) S(3,3) S(3,4) S(4,4)
#> 1    72      0      0      0      1      0      0      2      1      1      0
#> 2   144      0      0      0      1      0      1      1      0      2      0
#> 3    72      0      0      0      1      0      1      1      1      0      1
#> 4    72      0      0      0      1      0      2      0      0      1      1
#> 5    24      0      0      0      1      1      0      0      0      3      0
#> 6    36      0      0      0      1      1      0      0      1      1      1
#> 7    72      0      0      1      0      0      0      2      0      2      0
#> 8    36      0      0      1      0      0      0      2      1      0      1
#> 9   144      0      0      1      0      0      1      1      0      1      1
#> 10   18      0      0      1      0      0      2      0      0      0      2
#> 11   36      0      0      1      0      1      0      0      0      2      1
#> 12    9      0      0      1      0      1      0      0      1      0      2
#> 13   48      0      1      0      0      0      0      1      0      3      0
#> 14   72      0      1      0      0      0      0      1      1      1      1
#> 15   72      0      1      0      0      0      1      0      0      2      1
#> 16   18      0      1      0      0      0      1      0      1      0      2

# Print the representation of the 4-dimensional moment c(1,2,3,4):
print(callmultmoments(c(1,2,3,4)))
#> E[ X1^1 X2^2 X3^3 X4^4 ]: 
#>    coef S(1,1) S(1,2) S(1,3) S(1,4) S(2,2) S(2,3) S(2,4) S(3,3) S(3,4) S(4,4)
#> 1    72      0      0      0      1      0      0      2      1      1      0
#> 2   144      0      0      0      1      0      1      1      0      2      0
#> 3    72      0      0      0      1      0      1      1      1      0      1
#> 4    72      0      0      0      1      0      2      0      0      1      1
#> 5    24      0      0      0      1      1      0      0      0      3      0
#> 6    36      0      0      0      1      1      0      0      1      1      1
#> 7    72      0      0      1      0      0      0      2      0      2      0
#> 8    36      0      0      1      0      0      0      2      1      0      1
#> 9   144      0      0      1      0      0      1      1      0      1      1
#> 10   18      0      0      1      0      0      2      0      0      0      2
#> 11   36      0      0      1      0      1      0      0      0      2      1
#> 12    9      0      0      1      0      1      0      0      1      0      2
#> 13   48      0      1      0      0      0      0      1      0      3      0
#> 14   72      0      1      0      0      0      0      1      1      1      1
#> 15   72      0      1      0      0      0      1      0      0      2      1
#> 16   18      0      1      0      0      0      1      0      1      0      2

# Compute the LaTeX representation of the central moment c(1,2,3,4):
toLatex(callmultmoments(c(1,2,3,4)))
#>  [1] "E[X_{1}^{1}X_{2}^{2}X_{3}^{3}X_{4}^{4}]=\\\\"                             
#>  [2] "18\\sigma_{1,2}\\sigma_{2,3}\\sigma_{3,3}\\sigma_{4,4}^{2}+"              
#>  [3] "72\\sigma_{1,2}\\sigma_{2,3}\\sigma_{3,4}^{2}\\sigma_{4,4}+"              
#>  [4] "72\\sigma_{1,2}\\sigma_{2,4}\\sigma_{3,3}\\sigma_{3,4}\\sigma_{4,4}+"     
#>  [5] "48\\sigma_{1,2}\\sigma_{2,4}\\sigma_{3,4}^{3}+\\\\"                       
#>  [6] "9\\sigma_{1,3}\\sigma_{2,2}\\sigma_{3,3}\\sigma_{4,4}^{2}+"               
#>  [7] "36\\sigma_{1,3}\\sigma_{2,2}\\sigma_{3,4}^{2}\\sigma_{4,4}+"              
#>  [8] "18\\sigma_{1,3}\\sigma_{2,3}^{2}\\sigma_{4,4}^{2}+"                       
#>  [9] "144\\sigma_{1,3}\\sigma_{2,3}\\sigma_{2,4}\\sigma_{3,4}\\sigma_{4,4}+\\\\"
#> [10] "36\\sigma_{1,3}\\sigma_{2,4}^{2}\\sigma_{3,3}\\sigma_{4,4}+"              
#> [11] "72\\sigma_{1,3}\\sigma_{2,4}^{2}\\sigma_{3,4}^{2}+"                       
#> [12] "36\\sigma_{1,4}\\sigma_{2,2}\\sigma_{3,3}\\sigma_{3,4}\\sigma_{4,4}+"     
#> [13] "24\\sigma_{1,4}\\sigma_{2,2}\\sigma_{3,4}^{3}+\\\\"                       
#> [14] "72\\sigma_{1,4}\\sigma_{2,3}^{2}\\sigma_{3,4}\\sigma_{4,4}+"              
#> [15] "72\\sigma_{1,4}\\sigma_{2,3}\\sigma_{2,4}\\sigma_{3,3}\\sigma_{4,4}+"     
#> [16] "144\\sigma_{1,4}\\sigma_{2,3}\\sigma_{2,4}\\sigma_{3,4}^{2}+"             
#> [17] "72\\sigma_{1,4}\\sigma_{2,4}^{2}\\sigma_{3,3}\\sigma_{3,4}\\\\"

# evaluate the moment c(1,2,3,4) at the following variance-covariance matrix
#  4 2 1 1
#  2 3 1 1
#  1 1 2 1
evaluate(callmultmoments(c(1,2,3,4)), c(4,2,1,1,3,1,1,2,1,2))
#> [1] 3480
Metadata

Version

1.2.2

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows