truncnorm
truncnorm copied to clipboard
vtruncnorm: Variance is not calculated correctly
Hi,
vtruncnorm returns Inf for some parameters.
Example:
> vtruncnorm(0, 1, 1, .1)
[1] Inf
> vtruncnorm2 <- function(a, b, m, s) {
+ a <- (a - m) / s
+ b <- (b - m) / s
+ Z <- pnorm(b) - pnorm(a)
+ s^2 * (1 - (b * dnorm(b) - a * dnorm(a)) / Z - ((dnorm(b) - dnorm(a)) / Z)^2)
+ }
> vtruncnorm2(0, 1, 1, .1)
[1] 0.003633802
Best regards,
Jérôme
Hi,
I'm also facing this problem (and also with etruncnorm). Are there any actions planned to tackle this?
Thank you very much. Best regards Jan