Git Product home page Git Product logo

ewma's People

Contributors

aquayi avatar mend-for-github-com[bot] avatar pmatseykanets avatar pote avatar preetam avatar xaprb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ewma's Issues

Allow setting the EWMA's value

For some purposes, it's important to be able to set the EWMA's value directly. For example, suppose you keep track of a EWMA and then save it to a database, and later retrieve it and continue to add more values. (We do this at VividCortex.)

We should enhance the interface with an Add(float64) function, and implement these functions in our two public implementations. The semantics of Add should be to set the value and mark the EWMA as initialized, in case it has internal tracking of whether it's "warmed up" or not.

Use *float for SimpleEWMA

These properties let it use less memory. It will also behave differently when it's equal to zero, which is assumed to mean uninitialized, so if a value is likely to actually become zero over time, then any non-zero value will cause a sharp jump instead of a small change.

The disadvantages for SimpleEWMA like the sensitivity for 0 values could be solved by using *float64 for storing the value internally. Could do a PR if desired.

Go 1.10: ewma_test.go:39: Errorf format %d has arg e.Value() of wrong type float64

github.com/VividCortex/ewma 1.1.1 does not pass unit tests with Go 1.10:

+ GOPATH=/builddir/build/BUILD/ewma-1.1.1/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro  '\'''
# github.com/VividCortex/ewma
./ewma_test.go:39: Errorf format %d has arg e.Value() of wrong type float64
./ewma_test.go:53: Errorf format %d has arg e.Value() of wrong type float64
./ewma_test.go:83: Errorf format %d has arg e.Value() of wrong type float64
FAIL    github.com/VividCortex/ewma [build failed]

Inconsistency between doc and code

The readme says

So, for example, if you have a time-series with samples once per second, and you want to get the moving average over the previous minute, you should use an alpha of .032786885. This, by the way, is the constant alpha used for this repository's SimpleEWMA.

That alpha corresponds to N = 60, 2/(N+1) = 2/61 = .032786885.

The actual code uses 2/31:

ewma/ewma.go

Lines 8 to 14 in 487e8c9

// By default, we average over a one-minute period, which means the average
// age of the metrics in the period is 30 seconds.
AVG_METRIC_AGE float64 = 30.0
// The formula for computing the decay factor from the average age comes
// from "Production and Operations Analysis" by Steven Nahmias.
DECAY float64 = 2 / (float64(AVG_METRIC_AGE) + 1)

The readme may be using N with two different meanings in the section on "Choosing Alpha", but I don't think so. I think 2/31 is incorrect.

The comment in the code is also inconsistent with the readme. The readme talks about "N samples", whereas the code talks about "average age".

It's certainly possible I'm misunderstanding something.

Is this the same as exponential smoothing?

Before you file an issue, please consider:

We only accept pull requests for minor fixes or improvements. This includes:

  • Small bug fixes
  • Typos
  • Documentation or comments

Please open issues to discuss new features. Pull requests for new features will be rejected,
so we recommend forking the repository and making changes in your fork for your use case.

Tag the current state

I'm assuming the current state is stable. Could you please add a tag/release? This would make it easier for specifying versions for dep.

Test fail on arches ppc64le and s390x

Hello,

I am in the process of packaging ewma for Fedora but I encountered problems running the tests. On both ppc64le and s390x arches, the following test fails:

+ export GOPATH=/builddir/build/BUILDROOT/golang-github-VividCortex-ewma-0-0.1.git4cc8cc5.fc27.ppc64le//usr/share/gocode:/usr/share/gocode
+ GOPATH=/builddir/build/BUILDROOT/golang-github-VividCortex-ewma-0-0.1.git4cc8cc5.fc27.ppc64le//usr/share/gocode:/usr/share/gocode
+ go test -compiler gc -ldflags '' github.com/VividCortex/ewma
--- FAIL: TestSimpleEWMA (0.00s)
	ewma_test.go:26: e.Value() is 4734.500946466117, wanted 4734.500946466118
--- FAIL: TestVariableEWMA (0.00s)
	ewma_test.go:40: e.Value() is 4734.500946466117, wanted 4734.500946466118
FAIL
FAIL	github.com/VividCortex/ewma	0.018s

Could you identify why there is a discrepancy in the value given versus the value expected, only on these two arches while others arches test are fine?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.