Skip to content
Prev 392390 / 398503 Next

Need help

Dear Hossain,

Did you look at the values that your function returns? As John Nash 
pointed out, these values presumably depend on the random values of a and b.

I tried the following:

set.seed(123) # for reproducibility
a=rnorm(1000, 110, 5)
b = rnorm(1000, -0.3, 0.4)
s = length(a)
lam=0.15
thr=70
r= 10

ff = function(zz){
   inner = vector("numeric", length = s)
   for(k in 1:s){
     inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
   }
   answer = mean(inner)- (1- (1/r))
   return(answer)
}

res <- sapply(0:10000, ff)
res[1:500]
plot(0:150, res[1:151], type="l")


It was quickly clear that ff() produces NaNs for all but the smallest 
values of zz.

Beyond this fact, it's unclear to me what the purpose of the computation 
is. In the short domain where it produces numbers, the function returns 
both negative and positive values (for my values of a and b) -- that is, 
does cross 0 -- and if it did not, it would be nonsense to look for roots.

I hope this helps,
  John
On 2022-08-04 9:49 a.m., Md. Moyazzem Hossain wrote:
Message-ID: <3489b6ec-4ad3-d510-8d75-26b85bc8245a@mcmaster.ca>
In-Reply-To: <29425_1659621083_274DpMYL008226_CAO29qn6kLevZfJt1BrNN4KmcUR2sbFZdz5hZfFsQ-6041f9WCg@mail.gmail.com>