Code Monkey home page Code Monkey logo

gostats's Introduction

Build Status

gostats

Statistics for golang

Usage

To install, do go get github.com/r0fls/gostats. Check out gostats_test.go for a working example of using each distribution.

Example

package main

import (
    "fmt"
    "github.com/r0fls/gostats"
)

func main() {
    b := stats.Bernoulli(.5)
    fmt.Println(b.Random())

    // or fit a distribution from data...
    b = stats.FitBernoulli([0,1,1,1])
    fmt.Println(b.Random())
}

Distributions

Currently the following distributions are included:

  • Bernoulli
  • Laplace
  • Poisson
  • Geometric
  • Weibull
  • Exponential
  • Binomial
  • NegativeBinomial *

*note the negative binomial takes parameters r, p where r is the number allowed success before termination of the trials and p is the success of a given trial. The random variable produced by NegativeBinomial is the number of failures.

And each distribution has these functions:

  • Pmf or Pdf
  • Cdf
  • Quantile
  • Random

Also there is a corresponding function named FitDistrbution for each distribution, as shown in the above example with the Bernoulli. That function uses the MLE for each distribution to choose the best estimation for the parameters and returns an initialized distribution with them.

Common

Additionally there are some common functions. Most notably is LSR, which performs a least squares regression.

Additional Info

The default seed function is time.Now().UTC().UnixNano(). However you can override that by calling rand.Seed(uniqueInteger) yourself before generating random numbers.

Contributing

If you're interested in contributing, please submit a pull request, or raise an issue.

TO-DO
  • add more distributions
  • should random return an array?
  • allow updating a fitted distribution with more data

gostats's People

Contributors

r0fls avatar

Watchers

James Cloos avatar

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.