s-news
[Top] [All Lists]

Re: integrating

To: "'s-news@wubios.wustl.edu'" <s-news@wubios.wustl.edu>
Subject: Re: integrating
From: "Fox, G.J.A. (EDTE)" <G.J.A.Fox@edte.utwente.nl>
Date: Wed, 29 Jan 2003 15:26:06 +0100
Thanks to Bert Gunter,
who brought to my attention that (okay, it is in the manual) 
"f should be vectorized: the output of f(x,...) should be the length of x
and f(x,...)[i] should be the same as f(x[i],...)."
 
so I have changed the funcion into
 
integrand <- function(x) unlist(lapply(1:length(x), function(i,x,Y)
sum(log(dnorm(Y,mean=x[i],sd=1))),x=x,Y=Y))
 
now it is working.
 
-----Original Message-----
From: Fox, G.J.A. (EDTE) 
Sent: Wednesday, January 29, 2003 10:27 AM
To: 's-news@wubios.wustl.edu'
Subject: integrating



Hello,
 
I want to compute an integral (splus 6, win98), 

Y is a vector of real values length 100. 
integrand <- function(x) sum(log(dnorm(Y,mean=x,sd=1)))
 
this integrand function works fine.
integrate( integrand,lower=0,upper=1)$integral
 
this command gives the error stament
 
Problem in qf15(f, lower, upper, aux = optargs(list(...), f, 1)): f is not
vectorized - length(f(x))!=length(x) 
 
my question, what is the problem? 
Jean-Paul Fox.
 
_________________________________________________
 
dr.ir. G.J.A. Fox
Twente University
Faculty of Educational Science and Technology
 
PO. Box 217, 7500 AE Enschede
The Netherlands
 
E-Mail FoxJ@edte.utwente.nl <mailto:FoxJ@edte.utwente.nl> 

_________________________________________________

 
 


<Prev in Thread] Current Thread [Next in Thread>
  • integrating, Fox, G.J.A. (EDTE)
    • Re: integrating, Fox, G.J.A. (EDTE) <=