A good trick (I discovered accidentally) is to use the weight
![]() |
(16) |
| |
(17) |
![]() |
Because the second derivative is not positive everywhere,
the Cauchy function introduces the possibility of multiple solutions,
but because of the good results we see in Figure 4,
you might like to try it anyway.
Perhaps the reason it seems to work so well is that
it uses mostly residuals of ``average size,''
not the big ones or the small ones.
This happens because
is made from
and
the components of
which are a function
that is maximum for those residuals near
.
Module irls
supplies two useful
weighting functions that can be interchanged as arguments to the
reweighted scheme
.
#$=head1 NAME
#$
#$irls - weighting functions
#$
#$=head1 SYNOPSIS
#$
#$C<ierr=l1(res,weight)>
#$
#$C<ierr=cauchy(res,weight)>
#$
#$=head1 PARAMETERS
#$
#$=over 4
#$
#$=item res - C<real(:)>
#$
#$ Residual
#$
#$=item weight - C<real(:)>
#$
#$ Resulting weighting function
#$
#$=back
#$
#$=head1 DESCRIPTION
#$
#$Weighting function to apply to cgmethods (warning stability
#$is not guaranteed when using these).
#$
#$L1 - weight=1/abs(1+ res/rbar)
#$CAUCHY- weight=1/sqrt(1+res/rbar**2)
#$
#$
#$=head1 SEE ALSO
#$
#$L<solver>
#$
#$=head1 LIBRARY
#$
#$B<geef90>
#$
#$=cut
module irls {
use quantile_mod
contains
integer function l1 (res, weight) {
real, dimension (:) :: res, weight
real :: rbar
rbar = quantile( int( 0.5*size(res)), abs (res)) # median
weight = 1. / sqrt( sqrt (1. + (res/rbar)**2)); l1 = 0
}
integer function cauchy (res, weight) {
real, dimension (:) :: res, weight
real :: rbar
rbar = quantile( int( 0.5*size(res)), abs (res)) # median
weight = 1. / sqrt (1. + (res/rbar)**2); cauchy = 0
}
}