Issue link: http://dc.ee.ubm-us.com/i/71842

PROGRAMMER'S TOOLBOX • At the moment, the big question is: does this approach fix the parabolic fit's tendency to hang onto outlier points? Well, it might have, if I'd done it properly. In fact, though, it didn't, because I screwed up. let's not worry about that too much for now. We' ll be th inking harder about optimizing after we better understand the behavior. At the moment, the big question is: int para_shrink(double &xO, double &x1, double &x2, double &yO, double &y1, double &y2){ double too_close; #define MAX-PARA 4 static int count = MAX-PARA; if( count = OH } count = MAX-PARA; return FALSE; double x = para_fit(xO, x1, x2, yO, y1, y2); too_close = (x2 - xO)/20; if(max(x-xO, x2-x) < too_close){ count = MAX-PARA; return FALSE; } double y = f(x); if(x < x1 H if(y> y1H xO = x; yO = y; } else{ x2 = x1; y2 = y1; x1 = x; y1 = y; } } else{ if(y> y1H x2 = x; y2 = y; } else{ xO = x1; yO = y1; x1 = x; y1 = y; } } return TRUE; } We don ' t have to look very far to see the pro bl em: if you examine the 24 oaOBER 2000 Embedded Systems Programming To swap or not to swap does this approach fIX the parabolic fit 's tendency to hang onto outlier poin ts? Well, it might have, if I'd done it prop- erly. In fact, though, it didn 't, because I screwed up. The parabolic fit ended up giving me points tllat failed to satisfy our fundamentaJ requirement, that tlle middle point is always lowest. The problem is still in that pesky statement, wh ich was: i f( y > y1) last mo nth, and in Listing 1: i f« y > y1 ) && (x2 > xO» Turns out, neither test is correct. What I was trying to do was to swap Po and P2 if x turned o ut to be between XI and ~. That's because X is guaranteed to be between Xo and XI for the golden sec- tion, and I wanted it to look tlle same way after a parabolic fit. However, I fo rgot that, because of all the swapping, sometimes Xo is larg- e r than ~, and sometimes not. The correct test is: if«y > y1)*(x2 > xO) > 0) (Recognizing that this can be a risky test if Xo and ~ ar e drawing closer together, a we hope they do). So I can fix the test. Do we now get pe rforma nce whe re th e endpoints always move inward? No, we don 't. Figure 1 shows the case where I alter- nate between golden and parabolic methods. In Figure 2, I've set the fre- quency to allow two parabolic fits , then a forced golden section. It doesn 't seem to matter; the problem of end- poin ts stuck at the same vaJues persists.

- October001
- October002
- October003
- October004
- October005
- October006
- October007
- October008
- October009
- October010
- October011
- October012
- October013
- October014
- October015
- October016
- October017
- October018
- October019
- October020
- October021
- October022
- October023
- October024
- October025
- October026
- October027
- October028
- October029
- October030
- October031
- October032
- October033
- October034
- October035
- October036
- October037
- October038
- October039
- October040
- October041
- October042
- October043
- October044
- October045
- October046
- October047
- October048
- October049
- October050
- October051
- October052
- October053
- October054
- October055
- October056
- October057
- October058
- October059
- October060
- October061
- October062
- October063
- October064
- October065
- October066
- October067
- October068
- October069
- October070
- October071
- October072
- October073
- October074
- October075
- October076
- October077
- October078
- October079
- October080
- October081
- October082
- October083
- October084
- October085
- October086
- October087
- October088
- October089
- October090
- October091
- October092
- October093
- October094
- October095
- October096
- October097
- October098
- October099
- October100
- October101
- October102
- October103
- October104
- October105
- October106
- October107
- October108
- October109
- October110
- October111
- October112
- October113
- October114
- October115
- October116
- October117
- October118
- October119
- October120
- October121
- October122
- October123
- October124
- October125
- October126
- October127
- October128
- October129
- October130
- October131
- October132
- October133
- October134
- October135
- October136
- October137
- October138
- October139
- October140
- October141
- October142
- October143
- October144
- October145
- October146
- October147
- October148
- October149
- October150
- October151
- October152
- October153
- October154
- October155
- October156
- October157
- October158
- October159
- October160
- October161
- October162
- October163
- October164
- October165
- October166
- October167
- October168
- October169
- October170
- October171
- October172
- October173
- October174
- October175
- October176
- October177
- October178
- October179
- October180
- October181
- October182