I am generating two distributions (say, mean1, sd1 and mean2, sd2), using convolution on them and then calculating the integral for the newly generated distribution from a given threshold (a given maximum value) to Inf. Here, I am using functions from library distr.
Interestingly, when integrating, if my original distributions present values fairly larger than the threshold the output of the integral = 0 (should be = 100, indicating that the whole distribution falls after the threshold)
MWE
library(distr)
# Two distributions
mean1 <- 560
sd1 <- 4.1
mean2 <- 1570 # values to be tested: # 1570 # 1571 # 1970
sd2 <- 3.219
# Getting Normal Distribution for both groups
Np1 <- Norm(mean = mean1, sd = sd1)
Np2 <- Norm(mean = mean2, sd = sd2)
# Convolution of distributions
conv <- convpow(Np1 + Np2, 1)
# Sanity check
plot(conv)
# Distribution function
f.Z <- d(conv)
# This works well with any values.
min_threshold <- 1925.3
integrate(f.Z, 0, min_threshold, abs.tol = 0L)$value * 100
# The statement below provides abnormal output depending on the tested value presented above for mean2:
max_threshold <- 1968.9
integrate(f.Z, max_threshold, Inf, abs.tol = 0L)$value * 100
Here, I would expect that any value for mean2 > 1570 would have 100 as output, indicating a 100% chance of the distribution being after the max_threshold. Instead, output sharply decreases after 1570 until it reaches 0. Would anyone understand this behavior? Am I missing something here?
My machine has Windows 10, 64, R version 4.0.3, and library distr 2.8.0.
This code is based on the code provided here: integrate() in R gives terribly wrong answer
Many thanks!