title: I want to compute the Maximum Likelihood Estimator of a density but my output produces NaN's when mathematically my equations are correct
body: <p>I think my code is "almost correct", but why do I get NaN's?</p>
  
  <pre><code>N=100
  
  
  est1 = function(m){
  
  
  
    tau = rep(0,m)
  
    b0 = rep(0,m)
  
    b1 = rep(0,m)
  
    tau[1] = 1
  
    b0[1] = 1
  
    b1[1] = 1
  
    x&lt;- runif(100,0,1)
  
  
    for(i in 2:m){
  
      tau[i] = N/tau[i-1] + sum(log(y)) -(1 + exp(b0[i-1]+b1[i-1]*x) )*sum(y^tau[i-1]*log(y)/(1+y^tau[i-1]))  
  
      b0[i]= N - log(  1 +y^tau[i-1] )*sum( exp(b0[i-1]+b1[i-1]*x))
  
      b1[i] = (sum(x) )-log(1+y^tau[i-1])*sum( x*exp(b0[i-1]+ b1[i-1]*x ))
  
    }
  
    cbind(tau,b0,b1)
  }
  
  output = est1(100)
  
  output
  </code></pre>