# how to set a threshold based on normal distribution

"The values at p = 0.05 (one-sided) from a distribution of 5000 values, which is normal, was determined as the threshold"!

• I am learning stat by myself and I am trying to implement a method in R :) – EpiMan Sep 24 '15 at 13:55
• Then add the self-study tag. Also, do you know a priori that the data is normally distributed and you want to find the 95% quantile of the data or have you estimated the parameters for a normal distribution and want to find the quantile based in the parameters? – Gumeo Sep 24 '15 at 13:57
• The data is normally distributed. Therefore, "The values at p = 0.05 (one-sided) from a normal distribution" means 95% quantile of the data, did I get it correctly? @GuðmundurEinarsson would you explain a bit more? what does p = 0.05 mean in terms of PDF or CDF? – EpiMan Sep 24 '15 at 14:17
• I'm on the train, I'll write an answer when I get home in approximately 30 minutes. – Gumeo Sep 24 '15 at 14:33

If you simply want to calculate it in R, you can do it like this:

val.mean <- mean(values)
sd.mean <- sd(mean)
qnorm(0.95, val.mean, sd.mean)


You can calculate the sample quantile, which is independent of your normality assumption, but if your data is normally distributed, they should be approximately the same.

Here is some code to try this:

####################################
# Small demonstration on quantiles #
####################################

# Generate 5000 normally distributed values
# with mean mu and sd sigma
mu <- 27
sigma <- 20
x <- rnorm(5000,mu,sigma)

# Look at a histogram
hist(x,breaks=50)

# Quantile from data
print(quantile(x,probs=0.95))

# Quantile from parameters of a fitted normal distribution
print(qnorm(0.95,mean=mean(x),sd=sd(x)))


I get 59.58532 from the quantile function and 60.15717 from the qnorm function. They are very similar because my sample is generated from a normal distribution.

These are two different ways of doing this. It depends on your application of which method you would choose.