Skip to content

Commit

Permalink
Merge pull request #2 from cdemers/add-github-workflow-tests
Browse files Browse the repository at this point in the history
add github action tests and fix typos
  • Loading branch information
cdemers authored Feb 25, 2025
2 parents d17050b + f872f8a commit 0374378
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Go

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Run tests with race detection
run: |
export GO111MODULE=off
go test -v -race ./...
- name: Run coverage tests
run: |
export GO111MODULE=off
go test -v -cover ./...
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Simple Random Walker

**Simple random walker to be used for non cryptographic simulations, like
**Simple random walker to be used for non-cryptographic simulations, like
natural phenomenon models or finance**

[![GoDoc](https://godoc.org/github.com/cdemers/go-randomwalker?status.svg)](https://godoc.org/github.com/cdemers/go-randomwalker)
[![Go Report Card](https://goreportcard.com/badge/github.com/cdemers/go-randomwalker)](https://goreportcard.com/report/github.com/cdemers/go-randomwalker)

Package randomwalker provides a parametric random walk generator. You can
instantiate a random walker that will start at a specific point, that will stay
between an upper and lower boundary, that will vary on each step by a specified
Expand All @@ -16,18 +19,18 @@ Calling NewRandomWalker() returns a Gaussian like random walk generator. Once
created, you can call Step() on this object to get the first and then the
subsequent random walk value.

It's signature is `NewRandomWalker(origin, min, max, maxDynPcnt float32)`.
Its signature is `NewRandomWalker(origin, min, max, maxDynPcnt float32)`.

- The _origin_ parameter sets the initial walk value, it's starting point.
- The _min_ parameter sets a limit on how low can the walk go.
- The _max_ parameter sets a limit on how high the walk can go.
- The _maxDynPcnt_ parameter sets the limit on how much can a walk step vary from
it's previous value. Setting this value at zero will prevent the walk from
its previous value. Setting this value at zero will prevent the walk from
varying at all, leaving it constantly at it's initial value. Setting this
value at 1.0 will allow the walk step to vary from -50% to +50% of it's
value at 1.0 will allow the walk step to vary from -50% to +50% of its
previous value (the difference between -50% and +50% totaling 1.0). And
setting this value to more than 1.0 is permitted, for example setting it to 4.0
will allow a step to vary between -200% and +200% of it's previous value.
will allow a step to vary between -200% and +200% of its previous value.

Calling `Step()` afterward will return a float32 value.

Expand All @@ -48,7 +51,7 @@ rw = NewRandomWalker(origin, minimumWalkValue, maximumWalkValue, maximumVariatio
value = rw.Step()
// _value_ will be somewhere between (50 + 1%) and (50 - 1%).
value = rw.Step()
// _value_ will now be it's previous value plus or minus 1%.
// _value_ will now be its previous value plus or minus 1%.
```

# Development
Expand Down

0 comments on commit 0374378

Please sign in to comment.