R Under development (unstable) (2023-11-25 r85635 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(HyperbolicDist) > > ### Gamma distribution > k <- 4 > shape <- 2 > old <- 0 > new <- 1 > sampSize <- 1000000 > > ### Calculate 1st to 4th raw moments > m <- numeric(k) > for (i in 1:k){ + m[i] <- gamma(shape + i)/gamma(shape) + } > m [1] 2 6 24 120 > > ### Calculate 4th moment about new > momChangeAbout(k, m, old, new) [1] 53 > ### Calculate 3rd about new > momChangeAbout(3, m, old, new) [1] 11 > > ### Calculate 1st to 4th moments about new > momChangeAbout(oldMom = m, oldAbout = old, newAbout = new) [1] 1 3 11 53 > momChangeAbout(order = "all", m, old, new) [1] 1 3 11 53 > > ### Approximate kth moment about new using sampling > x <- rgamma(sampSize, shape) > mean((x - new)^k) [1] 53.04206 > > > proc.time() user system elapsed 0.40 0.06 0.40