This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5.1,3.5,1.4,0.2,Iris-setosa | |
4.9,3.0,1.4,0.2,Iris-setosa | |
4.7,3.2,1.3,0.2,Iris-setosa | |
4.6,3.1,1.5,0.2,Iris-setosa | |
5.0,3.6,1.4,0.2,Iris-setosa | |
5.4,3.9,1.7,0.4,Iris-setosa | |
4.6,3.4,1.4,0.3,Iris-setosa | |
5.0,3.4,1.5,0.2,Iris-setosa | |
4.4,2.9,1.4,0.2,Iris-setosa | |
4.9,3.1,1.5,0.1,Iris-setosa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A class to generate sample from Gaussian Distribution | |
# mean, standard-deviation and sample size are being | |
# expected to come from the user | |
library(R6) | |
library(ggplot2) | |
GaussianSimulator <- R6Class("GaussianSimulatorClass", | |
public = list( | |
mu = NA, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage of the class | |
# 1. create a new object of the class named `sm` | |
sm <- GaussianSimulator$new(mu=165, sigma=6.6, n_sample=1000) | |
# 2. generate a random sample | |
r <- sm$generate_sample() | |
# 3. compute basic ststistics of the sample | |
basic.stats <- sm$compute_stats() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ln.object <- LogNormalSimulator$new(mu = 5, sigma = 0.5, n_sample = 100000) | |
ln.sample <- test$generate_lognormal_sample() | |
ln.object$compute_stats() |