Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor docs fix #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Minor docs fix #27

wants to merge 1 commit into from

Conversation

jweissig
Copy link

@jweissig jweissig commented Jun 23, 2021

Was testing out the example snippet here and noticed the output was not as expected for a.Value(). I'm running go1.16.5 and I assume this is correct so submitted a docs fix. I ran the example code as shown from the readme but printed it.

Here's the code:

package main

import (
	"fmt"
	"github.com/VividCortex/ewma"
)

func main() {
	samples := [100]float64{
		4599, 5711, 4746, 4621, 5037, 4218, 4925, 4281, 5207, 5203, 5594, 5149,
	}

	e := ewma.NewMovingAverage()  //=> Returns a SimpleEWMA if called without params
	a := ewma.NewMovingAverage(5) //=> returns a VariableEWMA with a decay of 2 / (5 + 1)

	for _, f := range samples {
		e.Add(f)
		a.Add(f)
	}

	fmt.Println(e.Value()) //=> 13.577404704631077
	fmt.Println(a.Value()) //=> 1.5806140565521463e-12 <- fix here
}

Here's the output that I'm getting:

$ go run main.go
13.577404704631077
1.6330366675026306e-12

Was testing out the example snippet here and noticed the output was not as expected for `a.Value()`. I'm running go1.16.5 and I assume this is correct so submitted a docs fix. I can the example code as shown but printed it.

Here's the code:
```
package main

import (
	"fmt"
	"github.com/VividCortex/ewma"
)

func main() {
	samples := [100]float64{
		4599, 5711, 4746, 4621, 5037, 4218, 4925, 4281, 5207, 5203, 5594, 5149,
	}

	e := ewma.NewMovingAverage()  //=> Returns a SimpleEWMA if called without params
	a := ewma.NewMovingAverage(5) //=> returns a VariableEWMA with a decay of 2 / (5 + 1)

	for _, f := range samples {
		e.Add(f)
		a.Add(f)
	}

	fmt.Println(e.Value()) //=> 13.577404704631077
	fmt.Println(a.Value()) //=> 1.5806140565521463e-12 
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant