[R] French Curve

Michael A. Miller mmiller3 at iupui.edu
Tue Apr 5 17:28:21 CEST 2005


>>>>> "dream" == dream home <dreamhouse at gmail.com> writes:

    > Does it sound like spline work do the job? It would be hard
    > to persuave him to use some modern math technique but he
    > did ask me to help him implement the French Curve so he can
    > do his work in Excel, rather than PAPER.

Splines are useful for interpolating points with a continuous
curve that passes through, or near, the points.  If you are
looking for a way to estimate a curve with a noise component
removed, I think you'd be better off filtering your data, rather
than interpolating with a spline.  Median (or mean) filtering may
give  results similar to those from your chemist's manual
method.  That is easy to do with running from the gtools
package.  The validity of this is another question!

require(gtools)

x <- seq(250)/10
y1 <- sin(x) + 15 + rnorm(250)/2
y2 <- cos(x) + 12 + rnorm(250)

plot(x, y1, ylim=c(0,18), col='grey')
points(x, y2, pch=2, col='grey')
points(x, y1-y2, col='grey', pch=3)

## running median filters
lines(running(x), running(y1, fun=median), col='blue')
lines(running(x), running(y2, fun=median), col='blue')
lines(running(x), running(y1, fun=median)-running(y2, fun=median), col='blue')

## running mean filters
lines(running(x), running(y1), col='red')
lines(running(x), running(y2), col='red')
lines(running(x), running(y1)-running(y2), col='red')

f <- sin(x) + 15 - ( cos(x) + 12 )
lines(x, f)

Mike

-- 
Michael A. Miller                               mmiller3 at iupui.edu
  Imaging Sciences, Department of Radiology, IU School of Medicine




More information about the R-help mailing list