I've created a series of numbers using the rbeta
function.
set.seed(123)
n = 100000
p1.12.2 = rbeta(n, 0.3225928, 1.2903712)
p4.7.2 = (rbeta(n, 0.3488823, 3.1399407)^2)
E2 = p4.7.2*p1.12.2
This runs fine but I would like to find the mode of E2, so I've done this by getting the peak of the density plot.
d = density(E2)
i = which.max(d$y)
M2 = d$x[i]
M2
I keep getting a negative value for the mode. But the beta distribution is confined to 0-1. Any ideas where the negative values are coming from or is there another way to get the mode of a bin?