# I need an algorithm to best-fit a curve

1. May 29, 2012

### Jamin2112

I'm making an applet for distance runners that predicts their finish time for any distance, using recent race times for any distance. For example, a user might enter 3 recent race times which are 16:37 for a 5k (5:21 min/mile pace), 27:42 for an 8k (5:34 min/mile pace), and 35:18 for a 10k (5:41 min/mile pace), then my "finish time calculator" could predict their finish time for a race of any distance. I've found that distance vs. pace follows a logistic curve like the one pictured below.

http://luna.cas.usf.edu/~mbrannic/files/pmet/image329.gif [Broken]

Hence I want to predict their race finish times using a logistic function f(x) = C1(1/(1+C2e-C3x)). How do I do this, though?

Last edited by a moderator: May 6, 2017
2. May 29, 2012

### Number Nine

Standard non-linear regression problem. Any statistics software (e.g. R) will let you fit the curve fairly easily.

3. May 30, 2012

### Jamin2112

I was actually gonna recreate the algorithm in Javascript since I'm putting this "finish time calculator" on a site.

4. May 30, 2012

### hotvette

5. Jun 11, 2012

### Levex

You could try Lagrange Interpolation.
Although it may have divergence, it will certainly pass through those points.