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'
f2d <- function(n){
x <- replicate(1000, rpois(n, 10))
optimise(
f = function(theta){ sum(dpois(x, theta, log = TRUE)) },
interval = c(0,50),
maximum = TRUE
)
}