I have created a function to generate random poisson distributions but want the function to calculate the mean of lambda also.
xpoisson<-function(x,mu){rpois(x, lambda=mu)}
This is what I have written so far and Im not sure where/how to add the mean(mu)
to the function. Any help apppreciated.
I believe what you want is not mean(mu)
but mean(rpois(x,lamda=mu))
?
If so, just add the new line inside the function, assign the distribution and mean to variables and return both values by adding them to a list and returning said list.