Average relative distance between 2 functions

Anna Kaladze
Messages
34
Reaction score
0
Hi All,

Sorry perhaps for a stupid question, but I am pretty confused by this one...
Suppose I have two different smooth functions, f(x) and g(x) both defined on a closed interval [a,b]. How do I calculate the average relative distance between the all values of these functions (say relative to g(x))? (I do not care about +/- signs). If I had not had functions and only say, 2 discrete values, say, z1=10, y1=8 and z2=20, y2=18, then it would be easy I guess: (1/2)*[(10-8)/8+(20-18)/18]. But for the continuous functions? I assume I need to do some integrations, but my formulas ended up not making sense to me...Please help.

Regards,

Anna.
 
Last edited:
Mathematics news on Phys.org
P.S. I originally thought that the answer to my question is simply an integral from a to b of
([f(x)-g(x)]/g(x))dx all divided by (b-a) by I am not sure this is correct or not...
 
How about first calculating the avreage value of f(x) then calculating the avreage value of g(x)? Now you have those two, all you need is the avreage of those two.
 
Thanks for your reply. I wonder if you can please tell me what would be a formula for that using the integral? And also if the one I have posted myself as a possible solution is right or not. Thanks.
 
Anna Kaladze said:
Hi All,

Sorry perhaps for a stupid question, but I am pretty confused by this one...
Suppose I have two different smooth functions, f(x) and g(x) both defined on a closed interval [a,b]. How do I calculate the average relative distance between the all values of these functions (say relative to g(x))? (I do not care about +/- signs). If I had not had functions and only say, 2 discrete values, say, z1=10, y1=8 and z2=20, y2=18, then it would be easy I guess: (1/2)*[(10-8)/8+(20-18)/18]. But for the continuous functions? I assume I need to do some integrations, but my formulas ended up not making sense to me...Please help.

Regards,

Anna.

I'm guessing this won't help, but thinking statistically, if you can find the distribution of how values occur over your interval then you can use continuous expectation definition.

This however is probably more work than you need to do and might make your life more complex, but I'm just going from first principles using statistics.

I think the above definition of finding the integral and then dividing by the length of the interval should give the right answer and here is my reason:

Suppose you choose an interval that is purely decreasing or increasing: the probability of each value in the interval is the same (and you can picture this by drawing horizontal lines through the function). Now in a uniform distribution the pdf is (wait for it) 1/length of interval. So you can take the 1/(b-a) out of the integral and you are simply integrating your function.

Using additive properties of integrals you can calculate your required measures for any function.
 
Dear Chiro,
Thanks for reply. I forgot to mention that my functions are simple deterministic functions, and a and b are real numbers. The functions are continuous, like x^2 and x+2 defined over the interval [1,4] (just an example). I wonder if the formula I had still is correct. thanks
 
There are, in fact, many different ways of defining "distance" between two functions:
d(f, g)= max |f(x)- g(x)| if f and g are continuous functions on some closed and bounded interval [a, b] so we can be sure that maximum exists.
(The "uniform norm")

d(f, g)= \int_a^b |f(x)- g(x)|dx
provided that integral exists. (The "L1" norm)

d(f,g)= \sqrt{\int_a^b (f(x)- g(x))^2 dx}
provided that integral exists. (The "L2" norm)

or generally,
d(f,g)= \sqrt[n]{\int_a^b (f(x)- g(x))^n dx}
provided that integral exists. (The "Ln" norm)
 
Thanks a lot, Sir, for your clarifications.
Suppose I am interested in the uniform way, as your 1st formula. How do I compute the average relative distance on a closed interval [a,b]?
Thanks a lot.
 
Anna Kaladze said:
Thanks a lot, Sir, for your clarifications.
Suppose I am interested in the uniform way, as your 1st formula. How do I compute the average relative distance on a closed interval [a,b]?
Thanks a lot.

Well, if you have functions f and g on [a,b], then you just need to calculate the maximum value of |f-g| to know the distance between f and g.

For example, consider f(x)=x2 and g(x)=x on [0,1]. Then we need to know the maximum value of |x^2-x|. A little calculus yields that the derivative of x^2-x is 2x-1. And thus the maximum value occurs at 1/2. Thus

\max_{x\in [0,1]}{|x^2-x|}=|(1/2)^2-1/2|=1/4




However, judging from your posts, it seems that you're actually interesting in something else.
If x is fixed, then the distance between f and g at x is |f(x)-g(x)|. If you're looking for the average distance between f and g in [a,b], then it seems to me that you're actually looking for the average value of |f(x)-g(x)| in [a,b].

Now, for every function h in [a,b], we can calculate the average value as

\frac{1}{b-a}\int_a^b{h(t)dt}

So what you're interested in, is actually

\frac{1}{b-a}\int_a^b{|f(t)-g(t)|dt}

With our example of f(x)=x2 and g(x)=x in [0,1], the average distance becomes

\frac{1}{1-0}\int_0^1{|t^2-t|dt}=\int_0^1{(t-t^2)dt}=\frac{1}{2}-\frac{1}{3}

So the average distance is 1/6.
 
  • #10
Dear micromass,
Thank you for your thorough reply.
Yes, my question involving the distance was a bit confused as I mixed up the terminology a bit. But you are right, in a nutshell this is what I ws interested in.
However, I am interested in the average relative distance relative to g(x), for example. I think your formula is for the average only, yes?
Thanks a lot.
Anna.
 
  • #11
Anna Kaladze said:
Dear Chiro,
Thanks for reply. I forgot to mention that my functions are simple deterministic functions, and a and b are real numbers. The functions are continuous, like x^2 and x+2 defined over the interval [1,4] (just an example). I wonder if the formula I had still is correct. thanks

I was trying to point out how you could think of the analogy between expectation in the statistical sense and average in your case.

What you want to do is find the average of a continuous function and it seems you are having trouble finding it for the continuous case. All I was doing was to show you one analogy through the expectation formula of a continuous random variable.

I know your function is deterministic. It's probably not obvious what I am saying and for that I apologize. Maybe if your interested you can read the above post again.

The bottom line is that your intuition of taking the integral and dividing by the length of the integral is correct.
 

Similar threads

Replies
51
Views
3K
Replies
1
Views
1K
Replies
1
Views
1K
Replies
4
Views
2K
Replies
24
Views
2K
Replies
8
Views
3K
Replies
13
Views
2K
Replies
4
Views
1K
Back
Top