Skip to content

Instantly share code, notes, and snippets.

@koushikkhan
Created July 22, 2019 14:13
Show Gist options
  • Save koushikkhan/ba1e3719ab417fe14be85d33ac894c3a to your computer and use it in GitHub Desktop.
Save koushikkhan/ba1e3719ab417fe14be85d33ac894c3a to your computer and use it in GitHub Desktop.
LogNormalSimulator <- R6Class("LogNormalSimulatorClass",
inherit = GaussianSimulator,
public = list(
log_normal_sample = NA,
initialize = function(mu, sigma, n_sample) {
super$initialize(mu = mu, sigma = sigma, n_sample = n_sample)
},
generate_lognormal_sample = function() {
normal_sample <- self$generate_sample()
self$log_normal_sample <- exp(normal_sample)
return (self$log_normal_sample)
},
compute_stats = function() {
# Computes basic statistics of the sample
r <- list(sample.mean = mean(self$log_normal_sample),
sample.sd = sd(self$log_normal_sample))
return (r)
}
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment