# This file is part of the standard setup for testthat. # It is recommended that you do not modify it. # # Where should you do additional test configuration? # Learn more about the roles of various files in: # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview # * https://testthat.r-lib.org/articles/special-files.html library(PRNG) test_check("Random") library(testthat) # Define a test for the Uniformity Test test_that("Uniformity Test", { # Generate random numbers from your PRNG implementation random_numbers <- runf(n = 1000) # Adjust the sample size as needed # Perform the Kolmogorov-Smirnov test ks_result <- ks.test(random_numbers, "punif", 0, 1) # Test against a uniform distribution # Check if the p-value is greater than a significance level (e.g., 0.05) expect_true(ks_result$p.value > 0.05, "Generated random numbers do not follow a uniform distribution") }) # Define a test for the Independence Test test_that("Independence Test", { # Generate random numbers from your PRNG implementation #set.seed(123) # Set a seed for reproducibility random_numbers <- runf(n = 1000) # Generate 1000 random numbers (adjust sample size as needed) # Perform the autocorrelation test autocorr_result <- acf(random_numbers, plot = FALSE) # Check if the autocorrelation at lag 1 is close to 0 expect_true(abs(autocorr_result$acf[2]) < 0.05, # Check autocorrelation at lag 1 "Consecutive random numbers are not independent.") })