siddhi-io / siddhi

Stream Processing and Complex Event Processing Engine
http://siddhi.io
Apache License 2.0
1.53k stars 528 forks source link

stdDev() function returns incorrect result in conjunction to #window.length(N) #1647

Open xtrmstep opened 4 years ago

xtrmstep commented 4 years ago

Description: In conjunction with #window.length(N) the function stdDev() returns non 0 value or NaN when should return 0.

Affected Siddhi Version: 5.1.2

OS, DB, other environment details and versions:
Ubuntu, Docker latest version.

Steps to reproduce: Using this code

@App:name("test")
define stream input (
    id string,
    value double
);
partition with (id of input)
begin
    from input#window.length(3)
    select
        id,
        stdDev(value) as std
    insert into tmp;
end;
from tmp#log()
select *
insert into muted;

In editor try to send the following sequence of events a, 1 a, 2 a, 3 a, 3 a, 3 a, 3

stdDev() returns 8.603189426505949E-9 when should 0. It should return 0 because the last three values are 3,3,3 the returning value is not constant, it obviously some accumulated rounding error.

AnuGayan commented 4 years ago

I have tested this on Streaming Integrator which is based on siddhi 5.1.12 and couldn't observe the above behavior.

xtrmstep commented 4 years ago

@AnuGayan which docker images would you recommend to check? I'm using siddhiio/siddhi-tooling:5.1.2 and for running of applications siddhiio/siddhi-runner-base-alpine:5.1.2

xtrmstep commented 4 years ago

I've got multiple errors in my applications related to this. And this case was reproducing pretty stable on tooling 5.1.2

AnuGayan commented 4 years ago

You can try this on Streaming Integrator docker image

xtrmstep commented 4 years ago

I'll check, ok. But shouldn't be a docker image for Enterprise Integrator? As far i I know this is the latest and most fresh version.

AnuGayan commented 4 years ago

Streaming Integrator 1.x.x is a part of Enterprise Integrator 7.x.x offering and SI is the one which is based on Siddhi.