r - Vector with function as elements -


i'm try compute integral in r numerically :

enter image description here

where

enter image description here

cm , cf function know , gamma parameter known.

what wanted compute integral a=18,19,20,...,65 hence basically, construct vector of size 48 in first element pi(18), second pi(19),untill pi(65).

is possible in r ?

i have tried compute integrand inside lambda (just try if works) in following way

integrand <- vector(mode="numeric")  (i in 1:48){  integrand[i] <- function(a.f){exp(0.83-0.071*a.f)*  exp(-0.970774-0.077159*a.f)*  (1/sqrt(((-0.67+0.133*a.f)^{2})*pi))*exp(-(1/(-0.67+0.133*a.f)^{2})*(i-a.f- 2)^{2})} } 

but obtain error:

"incompatible types (from closure double) in subassignment type fix"

therefore have no clue on how solving initial integral.

if not mistaken, there. r powerful because vectorized, can use result:

a.f <- 1:48  integrand <- exp(0.83-0.071*a.f)*   exp(-0.970774-0.077159*a.f)*   (1/sqrt(((-0.67+0.133*a.f)^2)*pi))*   exp(-(1/(-0.67+0.133*a.f)^2)*(i-a.f- 2)^2) 

which gives vector (integrand) of length 48 values.

is want/need?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -