Re: [R] Integration of two lines

2011-01-26 Thread Xavier Robin
Hans W Borchers wrote : First define a function from those points: fx - approxfun(x, f_x) fy - approxfun(y, f_y) f - function(x) abs(fx(x)-fy(x)) and now you can apply integrate() or trapz(): xx - sort(c(x, y)) yy - f(xx) trapz(xx, yy) trapz() should

[R] Integration of two lines

2011-01-25 Thread Xavier Robin
Hello, I need to integrate the absolute difference between two lines measured on different points. # For example : x - seq(0, 1, 1/100) f_x - runif(101) + x y - seq(0, 1, 1/23) f_y - runif(24) + (1 - y) plot(x, f_x, type=l) lines(y, f_y) Then I would like to compute Integral( | f_x - f_y |

Re: [R] Integration of two lines

2011-01-25 Thread Rmh
g - function(x) abs(f1(x)-f2(x)) now you have one function and you can integrate it. Rich Sent from my iPhone On Jan 25, 2011, at 7:32, Xavier Robin xavier.ro...@unige.ch wrote: Hello, I need to integrate the absolute difference between two lines measured on different points. # For

Re: [R] Integration of two lines

2011-01-25 Thread Hans W Borchers
Xavier Robin Xavier.Robin at unige.ch writes: Hello, I need to integrate the absolute difference between two lines measured on different points. # For example : x - seq(0, 1, 1/100) f_x - runif(101) + x y - seq(0, 1, 1/23) f_y - runif(24) + (1 - y) plot(x, f_x, type=l) lines(y,

Re: [R] Integration of two lines

2011-01-25 Thread Xavier Robin
Le 25.01.2011 15:23, Rmh a écrit : g - function(x) abs(f1(x)-f2(x)) now you have one function and you can integrate it. Thank you Rich. Unfortunately I have no f1 and f2 functions, only a set of observed points on two lines - and no idea about the underlying distribution to create a