jeudi 4 novembre 2021

Generate samples of size n and apply function in R?

I have the following code to generate my samples of size n, then want to perform an optimise function on the samples. I should get 1000 results from the optimise function but only get 1? Is there a way to perform the optimise function across the rows of 'x'

  x = replicate(1000, rpois(n, 10))
  optimise(function(theta){
    sum(dpois(x, theta, log=TRUE))}, interval = c(0,50), maximum = TRUE)
}```



Aucun commentaire:

Enregistrer un commentaire