Search code examples
rstatisticsnormal-distribution

How do I draw a 2 normal distribution in one frame?


Here is the problem:

2 groups:

Group A: initial cholesterol levels were normally distributed with mean=244 mg/100 ml and standard deviation = 51 mg/100 ml.

Group B: initial cholesterol levels were normally distributed with mean= 219 mg/100 ml and standard deviation=41 mg/100 ml.

The question I need to answer is how do I produce two normal distributions (group A + Group B) in the same frame?

Do i use the command dnorm()?

Here is my attempt at the code:

curve(dnorm(x, mean=219, sd=41))

the height of the curve is 1/(sqrt(2*pi)*sd)


Solution

  • Yes you can use curve()+dnorm():

    curve(dnorm(x, mean=219, sd=41), from = 0, to = 400)
    curve(dnorm(x, mean=244, sd=51), add = TRUE, col = 2)
    

    enter image description here