<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hello,<br>
<br>
I have written a little script making the comparison between L1
and L2 norm. For the L1 case, I have used leastsq and cheated by
returning the square root of the abs of the residue and the 'nd'
option. <br>
<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:12.0;"><span style="color:rgb(176,24,19);">function</span> <span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(0,0,0);text-decoration:underline;">resid</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">coef</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">x</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">y</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">z</span><span style="color:rgb(74,85,219);">)</span>
<span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">sqrt</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(50,185,185);">abs</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">z</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">coef</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(131,67,16);font-weight:bold;">coef</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(131,67,16);font-weight:bold;">x</span><span st
yle="colo
r:rgb(92,92,92);">+</span><span style="color:rgb(131,67,16);font-weight:bold;">coef</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">3</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(131,67,16);font-weight:bold;">y</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(131,67,16);font-weight:bold;">r</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(176,24,19);">endfunction</span>
<span style="color:rgb(0,0,0);">n</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(188,143,143);">10</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">x</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">y</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(174,92,176);text-decoration:underline;">meshgrid</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(174,92,176);text-decoration:underline;">linspace</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">n</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">z</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(0,0,0);">x</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(0,0,0);">y</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(50,185,185);">rand</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">x</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">'</span><span style="color:rgb(188,143,143);">normal</span><span style="color:rgb(188,143,143);">'</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">/</span><span style="color:rgb(188,143,143);">10</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">z</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">n</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">n</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(188,143,143);">20</span><span style="color:rgb(0,0,0);">;</span> // outlier
<span style="color:rgb(0,0,0);">
// L2 case
A</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">x</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">^</span><span style="color:rgb(188,143,143);">0</span> <span style="color:rgb(0,0,0);">x</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(0,0,0);">y</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">coefl2</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(0,0,0);">A</span><span style="color:rgb(92,92,92);">\</span><span style="color:rgb(0,0,0);">z</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(50,185,185);">disp</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">coefl2</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
// L1 case
<span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">l1norm</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">coefl1</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(174,92,176);text-decoration:underline;">leastsq</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(50,185,185);">list</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);text-decoration:underline;">resid</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">x</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">y</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">z</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">coefl2</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);"
>'</span>
<span style="color:rgb(188,143,143);">nd</span><span style="color:rgb(188,143,143);">'</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(50,185,185);">disp</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">coefl1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span></pre>
<br>
Things are not supposed to work so well because 'nd' is only
meaning that the function to minimize in non-differentiable at the
optimum (and only there....). However, it seems to work well (true
value is [1,1,1]') :<br>
<br>
L2 case :<br>
<br>
1.165072 <br>
1.4380897 <br>
1.398408 <br>
<br>
L1 case :<br>
<br>
0.9954939 <br>
1.0441875 <br>
0.9939874 <br>
<br>
S.<br>
<br>
Le 04/03/13 18:51, Rafael Guerra a écrit :<br>
</div>
<blockquote cite="mid:DUB101-ds21CFD8BEE1F9A6746754ACCFA0@phx.gbl"
type="cite">
<pre wrap="">Thanks Stéphane for the useful L1-references and for the insight on
iterative L2 methods and to the others for their repplies.
PS:
Strong outliers or spikes have infinite bandwidth and therefore bandpass
filtering/convolution does not seem, a priori, to be the most effective
method to remove them.
Regards,
Rafael
-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:users-bounces@lists.scilab.org">users-bounces@lists.scilab.org</a> [<a class="moz-txt-link-freetext" href="mailto:users-bounces@lists.scilab.org">mailto:users-bounces@lists.scilab.org</a>]
On Behalf Of Stéphane Mottelet
Sent: Monday, March 04, 2013 10:14 AM
To: <a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
Subject: Re: [Scilab-users] Surface smoothing in Scilab, immune to outliers
Hello,
Replacing the squared L2 norm by the L1 norm in the linear regression gives
a good robustness to outliers (cf. Donoho and al. papers). The problem is
then non differentiable but you can implement it by iteratively reweighting
the classical L2 method (IRLS method), or by writing an equivalent linear
program.
S.
Le 04/03/13 13:23, Dang, Christophe a écrit :
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
De la part de Rafael Guerra
Envoyé : lundi 4 mars 2013 04:37
</pre>
<blockquote type="cite">
<pre wrap="">Does somebody know if there are Scilab functions [...] that smooths
experimental data z=f(x,y) and is immune to strong outliers.
</pre>
</blockquote>
<pre wrap="">imho, the problem with smoothing and outliers is that the definition
of a outlier depends on the field.
How can Scilab know what a "strong outlier" is?
I personally would try Fourier filtering:
a strong outlier means a steep slope
and therefore correspond to a high frequency.
Thus fft2, set high frequencies to 0
(with possibly a smooth transition),
then inverse fft2 -- ifft2 does not exist, I never used 2-dimension
Fourier transform so I don't know if the inverse is easy to perform...
</pre>
</blockquote>
<pre wrap="">
_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>