R version 4.5.0 beta (2025-03-27 r88067 ucrt) -- "How About a Twenty-Six" Copyright (C) 2025 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(GeneralizedHyperbolic) > data(ghypParam) > > test.ghypMean <- function(testParam = ghypSmallShape, n = 10000, + accuracy = 0.01) { + for (i in 1:nrow(testParam)) { + param <- testParam[i, ] + + # random number generation: + x <- rghyp(n, param = param) + + # Compute mean of the sample data: + sampleMean <- mean(x) + + # Get mean value from vgMean function: + funMean <- ghypMean(param = param) + + # Precision within the accuracy value? + difference <- abs(sampleMean - funMean) + cat("param", sep = "\n") + print(param) + cat("sample mean", sep = "\n") + print(sampleMean) + cat("function mean", sep = "\n") + print(funMean) + cat("difference", sep = "\n") + print(difference) + cat("checkTrue", sep = "\n") + print(checkTrue("test.ghypMean", difference < accuracy)) + } + } > > > test.ghypVar <- function(testParam = ghypSmallShape, n = 10000, + accuracy = 0.01) { + for (i in 1:nrow(testParam)) { + param <- testParam[i, ] + + # random number generation: + x <- rghyp(n, param = param) + + # Compute variance of the sample data: + sampleVar <- var(x) + + # Get mean value from vgVar function: + funVar <- ghypVar(param = param) + + # Precision within the accuracy value? + difference <- abs(sampleVar - funVar) + cat("param", sep = "\n") + print(param) + cat("sample variance", sep = "\n") + print(sampleVar) + cat("function variance", sep = "\n") + print(funVar) + cat("difference", sep = "\n") + print(difference) + cat("checkTrue", sep = "\n") + print(checkTrue("test.ghypVar", difference < accuracy)) + } + } > > test.ghypSkew <- function(testParam = ghypSmallShape, n = 10000, + accuracy = 0.01) { + for (i in 1:nrow(testParam)) { + param <- testParam[i, ] + + # random number generation: + x <- rghyp(n, param = param) + + # Compute skewness of the sample data: + sampleSkew <- DistributionUtils::skewness(x) + + # Get skewness value from vgSkew function: + funSkew <- ghypSkew(param = param) + + # Precision within the accuracy value? + difference <- abs(sampleSkew - funSkew) + cat("param", sep = "\n") + print(param) + cat("sample skewness", sep = "\n") + print(sampleSkew) + cat("function skewness", sep = "\n") + print(funSkew) + cat("difference", sep = "\n") + print(difference) + cat("checkTrue", sep = "\n") + print(checkTrue("test.ghypSkew", difference < accuracy)) + } + } > > test.ghypKurt <- function(testParam = ghypSmallShape, n = 10000, + accuracy = 0.01) { + for (i in 1:nrow(testParam)) { + param <- testParam[i, ] + + # random number generation: + x <- rghyp(n, param = param) + + # Compute kurtosis of the sample data: + sampleKurt <- DistributionUtils::kurtosis(x) + + # Get kurtosis value from vgKurt function: + funKurt <- ghypKurt(param = param) + + # Precision within the accuracy value? + difference <- abs(sampleKurt - funKurt) + cat("param", sep = "\n") + print(param) + cat("sample kurtosis", sep = "\n") + print(sampleKurt) + cat("function kurtosis", sep = "\n") + print(funKurt) + cat("difference", sep = "\n") + print(difference) + cat("checkTrue", sep = "\n") + print(checkTrue("test.ghypKurt", difference < accuracy)) + } + } > > checkTrue <- function(f, bool) { + if (bool) { + paste(f, ": PASS", sep = "") + } else { + paste(f, ": FAIL", sep = "") + } + } > > test.ghypMean() param [1] 0.0 1.0 99.0 0.0 -0.5 sample mean [1] -7.009881e-05 function mean [1] 0 difference [1] 7.009881e-05 checkTrue [1] "test.ghypMean: PASS" param [1] 0 1 99 0 0 sample mean [1] -0.0001660476 function mean [1] 0 difference [1] 0.0001660476 checkTrue [1] "test.ghypMean: PASS" param [1] 0 1 99 0 1 sample mean [1] -0.001236117 function mean [1] 0 difference [1] 0.001236117 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample mean [1] -1.507956 function mean [1] -1.507449 difference [1] 0.0005075112 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 -15.243 0.000 sample mean [1] -1.575174 function mean [1] -1.580304 difference [1] 0.005129937 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 -15.243 1.000 sample mean [1] -1.736481 function mean [1] -1.736109 difference [1] 0.0003719788 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 15.243 -0.500 sample mean [1] 1.519947 function mean [1] 1.507449 difference [1] 0.01249853 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 18.292 15.243 0.000 sample mean [1] 1.572694 function mean [1] 1.580304 difference [1] 0.007610263 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 15.243 1.000 sample mean [1] 1.732774 function mean [1] 1.736109 difference [1] 0.003335383 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample mean [1] -2.518914 function mean [1] -2.503846 difference [1] 0.01506781 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample mean [1] -3.543107 function mean [1] -3.542298 difference [1] 0.0008091075 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 -2.604 1.000 sample mean [1] -6.594413 function mean [1] -6.584913 difference [1] 0.009499973 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample mean [1] -0.468839 function mean [1] -0.474678 difference [1] 0.005838993 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 1.152 -0.494 0.000 sample mean [1] -0.651559 function mean [1] -0.6714271 difference [1] 0.01986811 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 1.152 -0.494 1.000 sample mean [1] -1.273551 function mean [1] -1.247806 difference [1] 0.02574463 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 1.152 0.494 -0.500 sample mean [1] 0.4880586 function mean [1] 0.474678 difference [1] 0.01338067 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 1.152 0.494 0.000 sample mean [1] 0.6676872 function mean [1] 0.6714271 difference [1] 0.003739983 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 1.152 0.494 1.000 sample mean [1] 1.263879 function mean [1] 1.247806 difference [1] 0.01607301 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 2.804 2.604 -0.500 sample mean [1] 2.511579 function mean [1] 2.503846 difference [1] 0.007733167 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 2.604 0.000 sample mean [1] 3.594437 function mean [1] 3.542298 difference [1] 0.05213836 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 2.804 2.604 1.000 sample mean [1] 6.544591 function mean [1] 6.584913 difference [1] 0.0403223 checkTrue [1] "test.ghypMean: FAIL" > test.ghypVar() param [1] 0.0 1.0 99.0 0.0 -0.5 sample variance [1] 0.01017173 function variance [1] 0.01010101 difference [1] 7.072132e-05 checkTrue [1] "test.ghypVar: PASS" param [1] 0 1 99 0 0 sample variance [1] 0.01010813 function variance [1] 0.0101519 difference [1] 4.376645e-05 checkTrue [1] "test.ghypVar: PASS" param [1] 0 1 99 0 1 sample variance [1] 0.01005265 function variance [1] 0.01025444 difference [1] 0.0002017853 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample variance [1] 0.3168646 function variance [1] 0.3236226 difference [1] 0.006757997 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 -15.243 0.000 sample variance [1] 0.3569074 function variance [1] 0.349894 difference [1] 0.007013423 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 -15.243 1.000 sample variance [1] 0.3980738 function variance [1] 0.4074875 difference [1] 0.009413656 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 15.243 -0.500 sample variance [1] 0.3164891 function variance [1] 0.3236226 difference [1] 0.007133423 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 15.243 0.000 sample variance [1] 0.3485801 function variance [1] 0.349894 difference [1] 0.001313922 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 15.243 1.000 sample variance [1] 0.4114046 function variance [1] 0.4074875 difference [1] 0.003917163 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample variance [1] 7.136556 function variance [1] 6.989659 difference [1] 0.1468966 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample variance [1] 12.49502 function variance [1] 12.13818 difference [1] 0.3568382 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 -2.604 1.000 sample variance [1] 27.58086 function variance [1] 28.85082 difference [1] 1.269959 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample variance [1] 1.175963 function variance [1] 1.177393 difference [1] 0.001429704 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 1.152 -0.494 0.000 sample variance [1] 1.765252 function variance [1] 1.746161 difference [1] 0.01909182 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 -0.494 1.000 sample variance [1] 3.404908 function variance [1] 3.470778 difference [1] 0.06587049 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 0.494 -0.500 sample variance [1] 1.245546 function variance [1] 1.177393 difference [1] 0.06815371 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 0.494 0.000 sample variance [1] 1.762561 function variance [1] 1.746161 difference [1] 0.01640089 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 0.494 1.000 sample variance [1] 3.463798 function variance [1] 3.470778 difference [1] 0.006980502 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 2.804 2.604 -0.500 sample variance [1] 6.941218 function variance [1] 6.989659 difference [1] 0.04844132 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 2.604 0.000 sample variance [1] 11.78913 function variance [1] 12.13818 difference [1] 0.3490496 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 2.604 1.000 sample variance [1] 28.48463 function variance [1] 28.85082 difference [1] 0.3661829 checkTrue [1] "test.ghypVar: FAIL" > test.ghypSkew() param [1] 0.0 1.0 99.0 0.0 -0.5 sample skewness [1] -0.03492518 function skewness [1] 0 difference [1] 0.03492518 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0 1 99 0 0 sample skewness [1] -0.0048763 function skewness [1] 0 difference [1] 0.0048763 checkTrue [1] "test.ghypSkew: PASS" param [1] 0 1 99 0 1 sample skewness [1] -0.004553416 function skewness [1] 0 difference [1] 0.004553416 checkTrue [1] "test.ghypSkew: PASS" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample skewness [1] -0.8327693 function skewness [1] -0.7861702 difference [1] 0.04659913 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 -15.243 0.000 sample skewness [1] -0.8553135 function skewness [1] -0.781198 difference [1] 0.07411556 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 -15.243 1.000 sample skewness [1] -0.7890551 function skewness [1] -0.7675085 difference [1] 0.0215466 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 15.243 -0.500 sample skewness [1] 0.7857003 function skewness [1] 0.7861702 difference [1] 0.0004699127 checkTrue [1] "test.ghypSkew: PASS" param [1] 0.000 1.000 18.292 15.243 0.000 sample skewness [1] 0.8237127 function skewness [1] 0.781198 difference [1] 0.04251474 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 15.243 1.000 sample skewness [1] 0.7402046 function skewness [1] 0.7675085 difference [1] 0.02730393 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample skewness [1] -2.780241 function skewness [1] -2.731917 difference [1] 0.0483236 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample skewness [1] -2.396644 function skewness [1] -2.371095 difference [1] 0.0255493 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 -2.604 1.000 sample skewness [1] -1.692121 function skewness [1] -1.759638 difference [1] 0.067517 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample skewness [1] -1.06623 function skewness [1] -1.261049 difference [1] 0.194818 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 -0.494 0.000 sample skewness [1] -1.294245 function skewness [1] -1.277531 difference [1] 0.01671359 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 -0.494 1.000 sample skewness [1] -1.131408 function skewness [1] -1.142286 difference [1] 0.01087842 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 0.494 -0.500 sample skewness [1] 1.258553 function skewness [1] 1.261049 difference [1] 0.002495056 checkTrue [1] "test.ghypSkew: PASS" param [1] 0.000 1.000 1.152 0.494 0.000 sample skewness [1] 1.259126 function skewness [1] 1.277531 difference [1] 0.01840484 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 0.494 1.000 sample skewness [1] 1.338078 function skewness [1] 1.142286 difference [1] 0.195792 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 2.604 -0.500 sample skewness [1] 2.647284 function skewness [1] 2.731917 difference [1] 0.08463364 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 2.604 0.000 sample skewness [1] 2.278711 function skewness [1] 2.371095 difference [1] 0.09238381 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 2.604 1.000 sample skewness [1] 1.764065 function skewness [1] 1.759638 difference [1] 0.004426242 checkTrue [1] "test.ghypSkew: PASS" > test.ghypKurt() param [1] 0.0 1.0 99.0 0.0 -0.5 sample kurtosis [1] 0.008844819 function kurtosis [1] 0.03030303 difference [1] 0.02145821 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0 1 99 0 0 sample kurtosis [1] 0.07450673 function kurtosis [1] 0.03030189 difference [1] 0.04420484 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0 1 99 0 1 sample kurtosis [1] -0.01235892 function kurtosis [1] 0.03029735 difference [1] 0.04265627 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample kurtosis [1] 0.9517493 function kurtosis [1] 1.120768 difference [1] 0.169019 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 -15.243 0.000 sample kurtosis [1] 0.9552408 function kurtosis [1] 1.094295 difference [1] 0.1390537 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 -15.243 1.000 sample kurtosis [1] 1.073529 function kurtosis [1] 1.034318 difference [1] 0.03921088 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 15.243 -0.500 sample kurtosis [1] 0.7598373 function kurtosis [1] 1.120768 difference [1] 0.360931 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 15.243 0.000 sample kurtosis [1] 1.063998 function kurtosis [1] 1.094295 difference [1] 0.03029657 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 15.243 1.000 sample kurtosis [1] 1.157864 function kurtosis [1] 1.034318 difference [1] 0.1235461 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample kurtosis [1] 10.1795 function kurtosis [1] 12.83578 difference [1] 2.656279 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample kurtosis [1] 7.733898 function kurtosis [1] 9.209436 difference [1] 1.475538 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 -2.604 1.000 sample kurtosis [1] 3.840174 function kurtosis [1] 4.804167 difference [1] 0.9639928 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample kurtosis [1] 4.341496 function kurtosis [1] 5.002984 difference [1] 0.6614881 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 -0.494 0.000 sample kurtosis [1] 3.251463 function kurtosis [1] 4.426761 difference [1] 1.175298 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 -0.494 1.000 sample kurtosis [1] 2.448337 function kurtosis [1] 2.992638 difference [1] 0.5443014 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 0.494 -0.500 sample kurtosis [1] 4.637385 function kurtosis [1] 5.002984 difference [1] 0.3655993 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 0.494 0.000 sample kurtosis [1] 5.045537 function kurtosis [1] 4.426761 difference [1] 0.6187767 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 0.494 1.000 sample kurtosis [1] 3.659032 function kurtosis [1] 2.992638 difference [1] 0.6663941 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 2.604 -0.500 sample kurtosis [1] 8.426895 function kurtosis [1] 12.83578 difference [1] 4.408884 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 2.604 0.000 sample kurtosis [1] 7.693842 function kurtosis [1] 9.209436 difference [1] 1.515594 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 2.604 1.000 sample kurtosis [1] 5.451786 function kurtosis [1] 4.804167 difference [1] 0.6476189 checkTrue [1] "test.ghypKurt: FAIL" > > proc.time() user system elapsed 5.32 0.12 5.39