Alex
Alex

Reputation: 1304

Truncated normal with a given mode

I would like to generate a random truncated normal distribution with the following properties.

  1. lower bound= 3
  2. higher bond= 5
  3. using a fixed set of values at the first digit(3.0,3.1,3.2,...,4.9,5.0)
  4. With mode=3
  5. the probability of 5 occurring should be 50% of the probability of 3 occurring.

I was able to deal with the first 3 steps but I am struggling to find a way to set mode=3 and to establish a fixed relationship on the occurrence of the higher and lower bound.

library(truncnorm)
library(ggplot2)
set.seed(123)
dist<- as.data.frame(list(truncnorm=round(rtruncnorm(10000, a=3, b=5, mean=3.3, sd=1),1)))
ggplot(dist,aes(x=truncnorm))+
  geom_histogram(bins = 40)+
  theme_bw()

enter image description here

As you can see I can create truncated normal with the desired boundaries. The problem with this distribution are two.

Upvotes: 1

Views: 269

Answers (1)

Peter O.
Peter O.

Reputation: 32878

Luckily, all your requirements are achievable using a truncated normal distribution.

Let low = 3 and high = 5.

Simply evaluate the density (at discrete points such as 3.0, 3.1, ..., 4.9, 5.0) of a normal distribution with mean low and standard deviation sqrt(2)*(high-low)/(2*sqrt(ln(2)).

This standard deviation is found by taking the following function proportional to a normal density with mean 0 and standard deviation z:

 f(x) = exp(-(x-0)**2/(2*z**2))

Since f(0) = 1, we must find the necessary standard deviation z such that f(x) = 1/2. The solution is:

 g(x) = sqrt(2)*x/(2*sqrt(ln(2))

And plugging high-low into x leads to the final standard deviation given above.

Upvotes: 3

Related Questions