Create random distribution based on configuration file
generate_random_values.RdThis function does the same thing as kwb.utils::generate_random_values(), but it is bundled with ambre to avoid a hard dependency on the unmaintained package.
References
Sonnenberg H (2024). kwb.utils: General Utility Functions Developed at KWB. R package version 0.15.0 URL: https://github.com/kwb-r/kwb.utils (MIT Licence)
Examples
# Example usage of generate_random_values
# Create a sample config object
config <- list(
type = "norm",
value = 10,
min = 5,
max = 15,
mean = 10,
sd = 2,
meanlog = log(10),
sdlog = 0.5,
mode = 10
)
# Call generate_random_values with the sample config
result <- generate_random_values(
config = config,
number_of_repeatings = 2,
number_of_events = 10,
debug = FALSE
)
# Print the results
cat("Simulated events:")
#> Simulated events:
print(result$events)
#> repeatID eventID values
#> 1 1 1 12.780708
#> 2 1 2 9.628517
#> 3 1 3 8.229293
#> 4 1 4 11.115832
#> 5 1 5 11.977835
#> 6 1 6 9.846005
#> 7 1 7 10.132986
#> 8 1 8 8.069863
#> 9 1 9 9.396153
#> 10 1 10 11.357362
#> 11 2 1 13.506611
#> 12 2 2 7.435721
#> 13 2 3 9.008389
#> 14 2 4 8.257585
#> 15 2 5 9.087613
#> 16 2 6 10.664732
#> 17 2 7 8.812670
#> 18 2 8 11.515820
#> 19 2 9 8.639734
#> 20 2 10 12.113586
cat("Parameters used for simulation:")
#> Parameters used for simulation:
print(result$paras)
#> type repeatings events mean sd
#> 1 norm 2 10 10 2