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(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] 0.0002796134 function mean [1] 0 difference [1] 0.0002796134 checkTrue [1] "test.ghypMean: PASS" param [1] 0 1 99 0 0 sample mean [1] -0.0004471915 function mean [1] 0 difference [1] 0.0004471915 checkTrue [1] "test.ghypMean: PASS" param [1] 0 1 99 0 1 sample mean [1] -2.872467e-05 function mean [1] 0 difference [1] 2.872467e-05 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample mean [1] -1.51502 function mean [1] -1.507449 difference [1] 0.007570712 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 -15.243 0.000 sample mean [1] -1.579702 function mean [1] -1.580304 difference [1] 0.0006022668 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 -15.243 1.000 sample mean [1] -1.720295 function mean [1] -1.736109 difference [1] 0.01581441 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 18.292 15.243 -0.500 sample mean [1] 1.516627 function mean [1] 1.507449 difference [1] 0.009177875 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 15.243 0.000 sample mean [1] 1.57954 function mean [1] 1.580304 difference [1] 0.0007639213 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 18.292 15.243 1.000 sample mean [1] 1.741577 function mean [1] 1.736109 difference [1] 0.005468104 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample mean [1] -2.547955 function mean [1] -2.503846 difference [1] 0.04410931 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample mean [1] -3.533083 function mean [1] -3.542298 difference [1] 0.009214914 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 -2.604 1.000 sample mean [1] -6.630715 function mean [1] -6.584913 difference [1] 0.04580194 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample mean [1] -0.4649771 function mean [1] -0.474678 difference [1] 0.009700926 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 1.152 -0.494 0.000 sample mean [1] -0.6720049 function mean [1] -0.6714271 difference [1] 0.0005777641 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 1.152 -0.494 1.000 sample mean [1] -1.227976 function mean [1] -1.247806 difference [1] 0.01983027 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 1.152 0.494 -0.500 sample mean [1] 0.4674187 function mean [1] 0.474678 difference [1] 0.007259241 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 1.152 0.494 0.000 sample mean [1] 0.688054 function mean [1] 0.6714271 difference [1] 0.01662685 checkTrue [1] "test.ghypMean: FAIL" param [1] 0.000 1.000 1.152 0.494 1.000 sample mean [1] 1.247794 function mean [1] 1.247806 difference [1] 1.216435e-05 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 2.604 -0.500 sample mean [1] 2.505327 function mean [1] 2.503846 difference [1] 0.00148109 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 2.604 0.000 sample mean [1] 3.543025 function mean [1] 3.542298 difference [1] 0.0007263588 checkTrue [1] "test.ghypMean: PASS" param [1] 0.000 1.000 2.804 2.604 1.000 sample mean [1] 6.585447 function mean [1] 6.584913 difference [1] 0.0005339522 checkTrue [1] "test.ghypMean: PASS" > test.ghypVar() param [1] 0.0 1.0 99.0 0.0 -0.5 sample variance [1] 0.01018535 function variance [1] 0.01010101 difference [1] 8.43422e-05 checkTrue [1] "test.ghypVar: PASS" param [1] 0 1 99 0 0 sample variance [1] 0.01027213 function variance [1] 0.0101519 difference [1] 0.0001202286 checkTrue [1] "test.ghypVar: PASS" param [1] 0 1 99 0 1 sample variance [1] 0.01054598 function variance [1] 0.01025444 difference [1] 0.0002915453 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample variance [1] 0.324599 function variance [1] 0.3236226 difference [1] 0.0009764128 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 -15.243 0.000 sample variance [1] 0.3496235 function variance [1] 0.349894 difference [1] 0.0002705154 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 -15.243 1.000 sample variance [1] 0.417986 function variance [1] 0.4074875 difference [1] 0.0104985 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 18.292 15.243 -0.500 sample variance [1] 0.3212502 function variance [1] 0.3236226 difference [1] 0.002372312 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 15.243 0.000 sample variance [1] 0.3519107 function variance [1] 0.349894 difference [1] 0.002016674 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 18.292 15.243 1.000 sample variance [1] 0.4044024 function variance [1] 0.4074875 difference [1] 0.003085111 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample variance [1] 6.879017 function variance [1] 6.989659 difference [1] 0.1106426 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample variance [1] 12.50249 function variance [1] 12.13818 difference [1] 0.3643078 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 -2.604 1.000 sample variance [1] 28.93148 function variance [1] 28.85082 difference [1] 0.08066085 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample variance [1] 1.21368 function variance [1] 1.177393 difference [1] 0.03628741 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 -0.494 0.000 sample variance [1] 1.630846 function variance [1] 1.746161 difference [1] 0.1153144 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 -0.494 1.000 sample variance [1] 3.467995 function variance [1] 3.470778 difference [1] 0.002783295 checkTrue [1] "test.ghypVar: PASS" param [1] 0.000 1.000 1.152 0.494 -0.500 sample variance [1] 1.142302 function variance [1] 1.177393 difference [1] 0.0350911 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 0.494 0.000 sample variance [1] 1.832264 function variance [1] 1.746161 difference [1] 0.0861036 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 1.152 0.494 1.000 sample variance [1] 3.404025 function variance [1] 3.470778 difference [1] 0.06675305 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 2.604 -0.500 sample variance [1] 6.541212 function variance [1] 6.989659 difference [1] 0.4484473 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 2.604 0.000 sample variance [1] 11.96551 function variance [1] 12.13818 difference [1] 0.1726687 checkTrue [1] "test.ghypVar: FAIL" param [1] 0.000 1.000 2.804 2.604 1.000 sample variance [1] 29.21858 function variance [1] 28.85082 difference [1] 0.367765 checkTrue [1] "test.ghypVar: FAIL" > test.ghypSkew() param [1] 0.0 1.0 99.0 0.0 -0.5 sample skewness [1] -0.02377496 function skewness [1] 0 difference [1] 0.02377496 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0 1 99 0 0 sample skewness [1] 0.02610081 function skewness [1] 0 difference [1] 0.02610081 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0 1 99 0 1 sample skewness [1] -0.01259362 function skewness [1] 0 difference [1] 0.01259362 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample skewness [1] -0.7705978 function skewness [1] -0.7861702 difference [1] 0.01557243 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 -15.243 0.000 sample skewness [1] -0.795934 function skewness [1] -0.781198 difference [1] 0.01473598 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 -15.243 1.000 sample skewness [1] -0.7688139 function skewness [1] -0.7675085 difference [1] 0.001305338 checkTrue [1] "test.ghypSkew: PASS" param [1] 0.000 1.000 18.292 15.243 -0.500 sample skewness [1] 0.873148 function skewness [1] 0.7861702 difference [1] 0.08697782 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 15.243 0.000 sample skewness [1] 0.7534298 function skewness [1] 0.781198 difference [1] 0.02776816 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 18.292 15.243 1.000 sample skewness [1] 0.7997912 function skewness [1] 0.7675085 difference [1] 0.0322827 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample skewness [1] -2.492014 function skewness [1] -2.731917 difference [1] 0.2399032 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample skewness [1] -2.199478 function skewness [1] -2.371095 difference [1] 0.1716176 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 -2.604 1.000 sample skewness [1] -1.758955 function skewness [1] -1.759638 difference [1] 0.0006831278 checkTrue [1] "test.ghypSkew: PASS" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample skewness [1] -1.395313 function skewness [1] -1.261049 difference [1] 0.1342647 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 -0.494 0.000 sample skewness [1] -1.305511 function skewness [1] -1.277531 difference [1] 0.02798028 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 -0.494 1.000 sample skewness [1] -1.071339 function skewness [1] -1.142286 difference [1] 0.07094764 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 0.494 -0.500 sample skewness [1] 1.30611 function skewness [1] 1.261049 difference [1] 0.04506179 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 0.494 0.000 sample skewness [1] 1.175227 function skewness [1] 1.277531 difference [1] 0.1023038 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 1.152 0.494 1.000 sample skewness [1] 1.082114 function skewness [1] 1.142286 difference [1] 0.06017243 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 2.604 -0.500 sample skewness [1] 2.55332 function skewness [1] 2.731917 difference [1] 0.1785975 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 2.604 0.000 sample skewness [1] 2.308271 function skewness [1] 2.371095 difference [1] 0.06282425 checkTrue [1] "test.ghypSkew: FAIL" param [1] 0.000 1.000 2.804 2.604 1.000 sample skewness [1] 1.833391 function skewness [1] 1.759638 difference [1] 0.07375205 checkTrue [1] "test.ghypSkew: FAIL" > test.ghypKurt() param [1] 0.0 1.0 99.0 0.0 -0.5 sample kurtosis [1] -0.07954401 function kurtosis [1] 0.03030303 difference [1] 0.109847 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0 1 99 0 0 sample kurtosis [1] -0.05960964 function kurtosis [1] 0.03030189 difference [1] 0.08991154 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0 1 99 0 1 sample kurtosis [1] -0.02336966 function kurtosis [1] 0.03029735 difference [1] 0.05366701 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 -15.243 -0.500 sample kurtosis [1] 1.046514 function kurtosis [1] 1.120768 difference [1] 0.07425451 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 -15.243 0.000 sample kurtosis [1] 1.086283 function kurtosis [1] 1.094295 difference [1] 0.008011273 checkTrue [1] "test.ghypKurt: PASS" param [1] 0.000 1.000 18.292 -15.243 1.000 sample kurtosis [1] 0.9914217 function kurtosis [1] 1.034318 difference [1] 0.04289613 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 15.243 -0.500 sample kurtosis [1] 0.9894127 function kurtosis [1] 1.120768 difference [1] 0.1313556 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 15.243 0.000 sample kurtosis [1] 1.07819 function kurtosis [1] 1.094295 difference [1] 0.01610442 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 18.292 15.243 1.000 sample kurtosis [1] 1.034515 function kurtosis [1] 1.034318 difference [1] 0.0001968989 checkTrue [1] "test.ghypKurt: PASS" param [1] 0.000 1.000 2.804 -2.604 -0.500 sample kurtosis [1] 13.41126 function kurtosis [1] 12.83578 difference [1] 0.5754772 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 -2.604 0.000 sample kurtosis [1] 10.99721 function kurtosis [1] 9.209436 difference [1] 1.787772 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 -2.604 1.000 sample kurtosis [1] 4.464836 function kurtosis [1] 4.804167 difference [1] 0.3393305 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 -0.494 -0.500 sample kurtosis [1] 6.822107 function kurtosis [1] 5.002984 difference [1] 1.819122 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 -0.494 0.000 sample kurtosis [1] 4.203638 function kurtosis [1] 4.426761 difference [1] 0.2231231 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 -0.494 1.000 sample kurtosis [1] 3.551374 function kurtosis [1] 2.992638 difference [1] 0.5587358 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 0.494 -0.500 sample kurtosis [1] 6.156924 function kurtosis [1] 5.002984 difference [1] 1.153939 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 0.494 0.000 sample kurtosis [1] 4.703441 function kurtosis [1] 4.426761 difference [1] 0.2766803 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 1.152 0.494 1.000 sample kurtosis [1] 3.284926 function kurtosis [1] 2.992638 difference [1] 0.2922882 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 2.604 -0.500 sample kurtosis [1] 10.67757 function kurtosis [1] 12.83578 difference [1] 2.158205 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 2.604 0.000 sample kurtosis [1] 6.091544 function kurtosis [1] 9.209436 difference [1] 3.117892 checkTrue [1] "test.ghypKurt: FAIL" param [1] 0.000 1.000 2.804 2.604 1.000 sample kurtosis [1] 4.530381 function kurtosis [1] 4.804167 difference [1] 0.2737863 checkTrue [1] "test.ghypKurt: FAIL" > > proc.time() user system elapsed 3.09 0.09 3.17