3
$\begingroup$

I need to compare the outputs of some functions and to rate their "erratness".

Given a function, the less erratic function between a and b would be a straight line and the more erratic function would probably be a triangular or sine wave, the bigger its amplitude or its frequency the bigger their erratness. I'm not sure if it's clear what I mean.

I've thought that a way to calculate it could be to calculate the length of the line generated by the function between a and b. The smaller the length the less erratic will be the function.

The questions are:

  1. Do you think this is a good way to achieve what I need?
  2. How can the length of the output of a function be calculated?

Thanks in advance.

  • 0
    You could look up the arclength integral...2012-04-14
  • 0
    No idea on what are you talking about :) (I'm not a mathematic) but I will take a look at wikipedia. Thanks!2012-04-14
  • 0
    Right, so type the words "arclength" and "integral" into your favorite search engine, and enjoy. Note that most such integrals do not have nice simple forms, and numerics would be needed.2012-04-14
  • 0
    Do you mean that they cannot be calculated by an algorithm? I'm developing software.2012-04-14
  • 0
    I meant that you **definitely** will need a numerical algorithm for this. Why exactly do you need to do this, anyway?2012-04-14
  • 0
    To determine which functions are more predictive than others. The more erratic the less predictive is it (IMHO).2012-04-14
  • 0
    Predictive for what?2012-04-14
  • 0
    Having a function between a and b I want to predict its values between b and c. I have a set of functions to choose from so the less erratic I think will be the easier to predict.2012-04-14
  • 1
    Stock Trading ...2012-04-14

2 Answers 2

4

There is something called the total variation of a function. If the function is differentiable, it's computed as $\int_a^b|f'(x)|\,dx$. There are standard methods for computing the derivative and the integral numerically. If the function is not differentiable, there's a different definition, which should also be suitable for numerical computation. See the discussion at http://en.wikipedia.org/wiki/Total_variation.

  • 0
    You rock man. That's what I was looking for and the wiki explanation is great. Thanks again.2012-04-14
3

If the end-use is an algorithm that must run quickly, your best bet is probably the sum squared difference (or SSD). If the line running between points $a$ and $b$ is: $$ y = mx +n$$ Then you want to sum the squared difference between each point $(x_i,y_i)$ and the line: $$SSD\equiv\sum{(y_i - mx_i -n)^2}$$

The smaller the $SSD$, the less "erratic" your function. Also note that if you have many points and not many computer cycles available, you may want to choose a small random subset of the points instead of summing over all of them.

  • 0
    Looks as a good way. I specially like the quadratic feature to penalize more the more erratic points. Thanks, you rock too.2012-04-14