Fitting a line by minimizing absolute deviation

In summary, the code minimizes a function by bisection, but the sign of the fx values for different values of b to bisect are the same, so no bisection step is taken.
  • #1
borson
30
0
Hey guys!.
I need to use this method of minimization.
The procedure to follow is explained here:
http://es.tinypic.com/r/35mmtg0/9
However, I do not fully understand. What do I have to do?
What I got from the paper is that I only have to minimize the equation 15.7.16, by using bisection. With this I am supposed to obtain the parameter b, whilst "a" would be got by means of 15.7.15 once the former is minimized and we know the true b.
Then, do I not have to do anything with 15.7.14?
Is it correct what I stated of how to perform the method or I am mistaken?
Thank you all!
 
Physics news on Phys.org
  • #2
borson said:
I only have to minimize the equation 15.7.16, by using bisection. With this I am supposed to obtain the parameter b, whilst "a" would be got by means of 15.7.15 once the former is minimized
No, you have to use both equations in finding b. For each trial value of b, use 15.7.15 to find the corresponding a, then evaluate the expression in 15.7.16. Adjust the choice of b according the "bracketing and bisection" procedure and repeat.
 
  • #3
haruspex said:
No, you have to use both equations in finding b. For each trial value of b, use 15.7.15 to find the corresponding a, then evaluate the expression in 15.7.16. Adjust the choice of b according the "bracketing and bisection" procedure and repeat.

Thanks for replying!

Then 15.7.14 is not used at all?
 
  • #4
borson said:
Thanks for replying!

Then 15.7.14 is not used at all?
.14 leads to, and is superseded by, the pair .15 and .16.
 
  • #5
haruspex said:
.14 leads to, and is superseded by, the pair .15 and .16.
Perfect. I designed the algorithm to perform it in that way. The problem is though, that the signs of Fx for the different values of b to bisect, after just one iteration, are the same!. Then no bisection step is taken. I do not understand why this is happening as 1) the function I am minimizing must have a root, 2) The interval to bisect that I am choosing contains that root. I am confused.
Thanks!
 
  • #6
By the way. Can someone explain me what finding a root going downhill means?
And how can I minimize that function (.16) if its "y" values (I mean, fx) are all of the same sign? (they should have different sign so that bisection could be applied)
Is it possible to bisect in that case?

thank you all!
 
  • #7
borson said:
Perfect. I designed the algorithm to perform it in that way. The problem is though, that the signs of Fx for the different values of b to bisect, after just one iteration, are the same!. Then no bisection step is taken. I do not understand why this is happening as 1) the function I am minimizing must have a root, 2) The interval to bisect that I am choosing contains that root. I am confused.
Thanks!
I'd need to see the data and some of the processing to figure out what is going wrong. Or maybe the coding?
 
  • #8
haruspex said:
I'd need to see the data and some of the processing to figure out what is going wrong. Or maybe the coding?

I think the whole code would be a bit tedious to read. I have gone over it some hundred of times and there is no mistake in that.
here is the function that I have to minimize (43)
http://es.tinypic.com/r/2m2iebr/9

And here is the data. http://es.tinypic.com/r/d4l8j/9.
Altogether with the results of the bisection.
h2 is the parameter to be bisected, which in 43 is "n". (h is an array, composed by the different values that n gets during bisection)
I give a 0,1 - 400 interval to bisect, and as it is seen in the results, the three "n"s, yield the same result in the equation .16 (named Fx in my code), thus, no further bisection step is taken.
Thank you for all!
 
  • #9
borson said:
here is the data
I cannot cut-and-paste from a screen snapshot. Please paste the data into a post as text.
 
  • #10
haruspex said:
I cannot cut-and-paste from a screen snapshot. Please paste the data into a post as text.
Oh of course, sorry.

{0.75, 64.36 }, //Time of a turn, final space in radians
{1.383, 33.50 },
{1.5, 28.29 },
{1.7, 21.449},
{1.0, 51.36},
{0.85, 58.242 },
{1.35, 34.12 },
 
  • #11
borson said:
Oh of course, sorry.

{0.75, 64.36 }, //Time of a turn, final space in radians
{1.383, 33.50 },
{1.5, 28.29 },
{1.7, 21.449},
{1.0, 51.36},
{0.85, 58.242 },
{1.35, 34.12 },
I find that to make the algorithm work you do need to start in the right ballpark.
Here are some values I got:
Code:
    b     a         sums
             15.7.16   15.7.14
-46.2 97.56  0.37       5.19
-46.4 97.76  0.37       5.27
-44   95.36 -0.93       7.09
-46   97.34 -0.78       5.24
-46.1 97.44 -0.13       5.18
-45   96.36 -0.93       6.16
-47   98.5   0.75       5.63
-45.5 96.86 -0.93       5.69
-46.5 97.86  0.37       5.3
So it is converging somewhere around b=-46.1.

Edit: I notice that it goes a bit crazy when one of the sgn() arguments is exactly zero. The recommended procedure of setting the value returned to zero does not fix it. Might be something to with the median function - that might need some tweaking. Look at b=-46.08.
 
Last edited:
  • #12
haruspex said:
I find that to make the algorithm work you do need to start in the right ballpark.
Here are some values I got:
Code:
    b     a         sums
             15.7.16   15.7.14
-46.2 97.56  0.37       5.19
-46.4 97.76  0.37       5.27
-44   95.36 -0.93       7.09
-46   97.34 -0.78       5.24
-46.1 97.44 -0.13       5.18
-45   96.36 -0.93       6.16
-47   98.5   0.75       5.63
-45.5 96.86 -0.93       5.69
-46.5 97.86  0.37       5.3
So it is converging somewhere around b=-46.1.

Edit: I notice that it goes a bit crazy when one of the sgn() arguments is exactly zero. The recommended procedure of setting the value returned to zero does not fix it. Might be something to with the median function - that might need some tweaking. Look at b=-46.08.
which values for phi have you used? (I mean, for the second parameter to find out in equation 42) I already know its right phi value, which is 6.19
Still, using that value, my bisection does not work.
Thanks!
 
  • #13
borson said:
which values for phi have you used? (I mean, for the second parameter to find out in equation 42) I already know its right phi value, which is 6.19
Still, using that value, my bisection does not work.
Thanks!
I just took the data values you posted (#10) as (x, y) pairs and applied the algorithm.
 

Related to Fitting a line by minimizing absolute deviation

1. What is the purpose of fitting a line by minimizing absolute deviation?

The purpose of fitting a line by minimizing absolute deviation is to find the best-fit line that minimizes the difference between the observed data points and the predicted values. This helps to make more accurate predictions and infer relationships between variables.

2. How is fitting a line by minimizing absolute deviation different from other methods?

Fitting a line by minimizing absolute deviation differs from other methods such as least squares in that it minimizes the sum of the absolute differences between the data points and the line, rather than the squared differences. This makes it more robust to outliers in the data.

3. What is the algorithm used for fitting a line by minimizing absolute deviation?

The algorithm used for fitting a line by minimizing absolute deviation is the Least Absolute Deviations (LAD) algorithm. This involves finding the line that minimizes the sum of the absolute deviations from the data points to the line, using an iterative process.

4. What are the advantages of using absolute deviation for line fitting?

One advantage of using absolute deviation for line fitting is that it is more resistant to outliers in the data. This means that it can provide a more accurate fit even when there are extreme values in the data. Additionally, it is less sensitive to the choice of units used for the variables.

5. Are there any limitations to fitting a line by minimizing absolute deviation?

One limitation of fitting a line by minimizing absolute deviation is that it is a less commonly used method compared to least squares, so there may be less resources and support available for implementing it. Additionally, it may not be suitable for data sets with a large number of variables or highly complex relationships between variables.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
928
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
28
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
930
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
13
Views
1K
  • Programming and Computer Science
Replies
4
Views
732
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
859
Back
Top