Average relative distance between 2 functions

In summary, the conversation discusses calculating the average relative distance between two smooth functions defined on a closed interval [a,b]. The first person is confused on how to calculate this and gives an example of how they would calculate it for discrete values. They ask for help in finding a formula using integrals. The second person suggests different ways of defining "distance" between functions and clarifies the formula for calculating the average distance. The third person asks for the formula for calculating the average relative distance, and the conversation ends with the fourth person thanking the others for their replies.
  • #1
Anna Kaladze
35
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
  • #2
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...
 
  • #3
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.
 
  • #4
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.
 
  • #5
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.
 
  • #6
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
 
  • #7
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")

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

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

or generally,
[tex]d(f,g)= \sqrt[n]{\int_a^b (f(x)- g(x))^n dx}[/tex]
provided that integral exists. (The "Ln" norm)
 
  • #8
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.
 
  • #9
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 [itex]|x^2-x|[/itex]. A little calculus yields that the derivative of [itex]x^2-x[/itex] is 2x-1. And thus the maximum value occurs at 1/2. Thus

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




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

[tex]\frac{1}{b-a}\int_a^b{h(t)dt}[/tex]

So what you're interested in, is actually

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

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

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

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.
 

Related to Average relative distance between 2 functions

1. What is the definition of average relative distance between 2 functions?

The average relative distance between 2 functions is a measure of the average difference between the values of two functions at the same input values. It is calculated by taking the absolute difference between the two functions at each input value, dividing it by the average of the two functions at that input value, and then averaging these ratios over all input values. In other words, it is a way to quantify how much the values of two functions deviate from each other on average.

2. How is average relative distance between 2 functions different from other distance measures?

Unlike other distance measures, such as absolute distance or percentage difference, average relative distance takes into account the scale of the functions being compared. This means that it can be useful for comparing functions with different units or different magnitudes of values. It also provides a more intuitive understanding of the difference between two functions, as it is expressed as a percentage rather than an absolute value.

3. Can average relative distance between 2 functions be negative?

No, average relative distance between 2 functions cannot be negative. This is because it is calculated by taking the absolute difference between the two functions, meaning that the result will always be a positive value. However, it is possible for the result to be close to 0, indicating that the two functions are very similar.

4. How is average relative distance between 2 functions used in scientific research?

Average relative distance between 2 functions is commonly used in fields such as statistics, data analysis, and machine learning. It can be used to compare the performance of different models, to assess the similarity of data sets, or to identify outliers in a data set. It is also a useful tool for evaluating the accuracy of predictions or simulations.

5. Are there any limitations to using average relative distance between 2 functions?

While average relative distance between 2 functions is a useful measure, it does have some limitations. It may not be suitable for comparing functions with drastically different shapes or for functions that have a lot of variability in their values. Additionally, it is important to consider the context and purpose of the comparison, as there may be more appropriate distance measures to use in certain situations.

Similar threads

  • General Math
2
Replies
51
Views
2K
Replies
1
Views
670
  • General Math
Replies
1
Views
739
Replies
5
Views
724
  • General Math
Replies
1
Views
893
  • General Math
Replies
24
Views
2K
  • General Math
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
837
  • General Math
Replies
13
Views
2K
  • General Math
Replies
8
Views
2K
Back
Top