[Scilab-users] "Smoothing" very localised discontinuities in (scilab: to exclusive) curves.
Rafael Guerra
jrafaelbguerra at hotmail.com
Mon Apr 4 14:58:47 CEST 2016
If your data is not recorded in real-time, you can sort it (along the x-axis)
and this does not imply that the "y(x) function" will become monotonous. See
below.
As suggested, by Stephane Mottelet, see one 3-point median filter solution below
applied to data similar to yours:
M = [1.0 -0.2;
1.4 0.0;
2.1 0.2;
1.7 0.45;
2.45 0.5;
2.95 0.6;
2.5 0.75;
3.0 0.8;
3.3 1.2];
x0 = M(:,1);
y0 = M(:,2);
clf();
plot2d(x0,[y0 y0],style=[5 -9]);
[x,ix] = gsort(x0,'g','i'); // sorting input x-axis
y = y0(ix);
k =1; // median filter half-lenght
n = length(x);
x(2:n+1)=x; y(2:n+1)=y;
x(1)=x(2); y(1)=y(2);
x(n+2)=x(n+1); y(n+2)=y(n+1);
n = length(x);
for j = 1:n
j1 = max(1,j-k);
j2 = min(n,j+k);
ym(j) = median(y(j1:j2));
end
plot2d(x,ym+5e-3,style=[3],leg="3-point median filtering@"); // shift for
display purposes
This gets rid of obvious outliers but does not guarantee a monotonous output
(idem for the more robust LOWESS technique, that can be googled).
Rafael
-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of
scilab.20.browseruk at xoxy.net <mailto:scilab.20.browseruk at xoxy.net>
Sent: Monday, April 04, 2016 1:05 PM
To: users at lists.scilab.org <mailto:users at lists.scilab.org>
Subject: Re: [Scilab-users] "Smoothing" very localised discontinuities in
(scilab: to exclusive) curves.
Yes.
C:\Motor>graphRdat T HB1M_Core25_No_Field_No_Epoxy_800Am.rdat
s = splin( h', b', 'monotone' );
!--error 999
splin: Wrong value for input argument #1: Not (strictly) increasing or +-inf
detected.
at line 22 of exec file called by :
Since there are no inf values in the data; that kind of implies that it requires
monotonic input in order to produce monotonic output; which ain't so useful.
That said, I get that same error message whichever variation of the splin()
function I try....
Which suggests there's something wrong with my data, but that stupid cos the
data is real.
The math has to adapt to the data not the other way around.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160404/b4b168a6/attachment.htm>
More information about the users
mailing list