# issue with usage of dnorm

Hi.
I need to show that the average density of the standard regular distribution is as below in the 0.5 intervals from –4 to 4, but these numbers are not available, so I have a problem.
Which part should I correct to get that number?
The number I need to prove : 0.000 0.002 0.010 0.033 0.088 0.184 0.300 0.383 0.383 0.300 0.184 0.088 0.033 0.010 0.002 0.000
x_dnorm <- seq (-4, 4, 0.5)
y_dnorm <- dnorm(x_dnorm)
round(y_dnorm,3)

Then I get 0.000 0.001 0.004 0.018 0.054 0.130 0.242 0.352 0.399 0.352 0.242 0.130
0.054 0.018 0.004 0.001 0.000

I cannot find where is the wrong point

R is correct, it gives you the density at each of the 17 values of x you requested.
You are trying to prove something about 16 values of y (at presumably 16 values of x ?)
or you mean by average density that you want to calculate an average of the densities between the intervals, rather that the actual densities at the break points.

I think I should calculate an average of the densities between the intervals.

``````library(tidyverse)
(mydf <- enframe(seq (-4, 4, 0.5),value="break1",name="breaknum"))

(mydf2 <- mutate(mydf,
break2 = lead(break1)) %>% na.omit() %>%
rowwise() %>%
mutate(inner_breaks = list(seq(from=break1,
to=break2,
length.out=1000)),
dnorm_vals = list(dnorm(inner_breaks)),
ave_dnorm_val = mean(dnorm_vals)))

#results
pull(mydf2,ave_dnorm_val) %>% round(digits=3)
#[1] 0.000 0.002 0.010 0.033 0.088 0.184 0.300 0.383 0.383 0.300 0.184 0.088 0.033 0.010 0.002 0.000``````
1 Like

Omg thank you sooo much!!! Have a great day

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.