in reply to Estimating continuous functions
But nobody has given you a simple to implement "OK" answer. Not great. Just something that can readily be implemented which gives an answer that you can defend as somewhat reasonable. Depending on the application, this is often enough.
Here is an outline of one.
Let's say that the last variable a function of the rest, call it f. Make f(x_1, x_2, ... , x_(n-1)) into the weighted average of the known values of f at the points that you have. A reasonable weighting is that a point is weighted with weight 1/(square of distance from that point to the spot you're estimating). Then you can do it something like this (with some error checking added, of course...):
This works perfectly well. The resulting function is trivially smooth everywhere except at the estimating points, and I'msub make_estimator { return sub {0} unless @_; # You might want to die? my @points = @_; return sub { my $weight_total; my $weighted_sum; foreach my $point (@points) { my $dist_squared = 0; foreach my $coord (0..$#_) { $dist_squared += ($point->[$coord] - $_[$coord])**2; } if (0 == $dist_squared) { return $point->[-1]; } else { my $weight = 1/$dist_squared; $weight_total += $weight; $weighted_sum += $weight * $point->[-1]; } } return $weighted_sum/$weight_total; }; } my $estimator = make_estimator( [3, 4], [4, 5], ); print $estimator->(3.5);
Feel free to play with the weighting function.
Update: I verified it. The function is also smooth at the estimating points. Its derivative at all estimating points is 0 (ie each is a maxima, minima, or inflection point).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(zdog) Re: (2) Estimating continuous functions
by zdog (Priest) on Mar 30, 2004 at 04:37 UTC | |
by tilly (Archbishop) on Mar 30, 2004 at 05:33 UTC | |
by zdog (Priest) on Mar 30, 2004 at 07:39 UTC | |
by Itatsumaki (Friar) on Mar 30, 2004 at 09:01 UTC | |
by tilly (Archbishop) on Mar 30, 2004 at 17:17 UTC | |
|
Re: Re: Estimating continuous functions
by Itatsumaki (Friar) on Mar 30, 2004 at 05:20 UTC |