Re: [R] Quicker way to apply values to a function

2012-03-23 Thread casperyc
Hi Petr, Thanks for confirming that the integral is bounded. I was thinking about the same thing. However, this requires that 'sigma' is positive. The actual problem occurred in my optimization routine, where i have set the parameter sigma=exp(para), where para is the logit of a uniform random

Re: [R] Quicker way to apply values to a function

2012-03-23 Thread Petr Savicky
On Thu, Mar 22, 2012 at 04:17:20PM -0700, casperyc wrote: > Hi all, > myint=function(mu,sigma){ > integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value > } > > mymu=seq(-3,3,length(1000)) > mysigma=seq(0,1,length(500))[-1] > > k=1 > v=c() > for (j in 1:length(mymu)) { >

Re: [R] Quicker way to apply values to a function

2012-03-22 Thread R. Michael Weylandt
I'd imagine one could solve this problem analytically (divergence/convergence *almost certainly* [hint cough!]closed form value seems hard) but perhaps you want to loop over a matrix instead: v <- matrix(NA, ncol = length(mymu), nrow = length(mysigma)) rownames(v) <- mysigma colnames(v) <- mym