I have a trouble when running my R code. It contains a few functions, but the problem happens when the following function is called:
w <- function(p) {
if (p == 1) pr <- 1
if (p == 0) pr <- 0
if (p != 0 && p != 1) pr <- exp(-(-log(p))^sigma)
return(pr)
}
The problem occurs when the argument of this w function becomes 1. I checked it with step by step execution. I found that when I have w(c1) in the other function and c1 has the value of 1, than the return of my w function is NaN. I am really confused because when I simply write w(1), I get 1, but when I have w(c1), where c1 was computed to be 1 in the other function, then w function does not work. In step by step execution, when c1 becomes 1, the first if condition suddenly does not work, it returns FALSE, but it should be the opposite, since c1 does equal 1.
What can be the solution to this problem?
Aucun commentaire:
Enregistrer un commentaire