Skip to content

Instantly share code, notes, and snippets.

@dlakelan
Last active February 4, 2022 18:08
Show Gist options
  • Save dlakelan/315f85ea5436b5bcbcc195c241094f5d to your computer and use it in GitHub Desktop.
Save dlakelan/315f85ea5436b5bcbcc195c241094f5d to your computer and use it in GitHub Desktop.
Sampling from non-normal distributions yields
# julia code to show that the mean of 14 samples from a 50/50 mixture
# of normal and uniform has extremely close to "normal" distribution
using Distributions, StatsPlots
meanvals = [mean([rand(Normal(0,1),7); rand(Uniform(-1,1),7)]) for i in 1:100000]
histogram(meanvals)
pop = [rand(Normal(0,1),10000); rand(Uniform(-1,1),10000)];
histogram(pop)
expmeans = [mean(rand(Exponential(1.0),14)) for i in 1:100000]
histogram(expmeans)
@dlakelan
Copy link
Author

dlakelan commented Feb 4, 2022

image

@dlakelan
Copy link
Author

dlakelan commented Feb 4, 2022

Above is the histogram of the sample means.... Here is the population that you're drawing from... very NON normal:

image

@dlakelan
Copy link
Author

dlakelan commented Feb 4, 2022

Here's the histogram of mean values from 14 exponentially distributed random variables.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment