GithubHelp home page GithubHelp logo

scolobb / random-fu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haskell-numerics/random-fu

0.0 2.0 0.0 933 KB

A suite of Haskell libraries for representing, manipulating, and sampling random variables

Haskell 100.00%

random-fu's Introduction

Random-fu

Random-number generation based on modeling random variables as first-class entities. This library currently consists of 3 major parts:

rvar

This package defines the central datatype of the system, a monad transformer called RVarT which extends an arbitrary monad with non-backtracking nondeterminism. In particular, the RVar type (an alias for RVar Identity) models pure random variables.

random-source

This package provides the backend for RVarT; arbitrary sources of entropy. Its design is still in major flux.

random-fu

This package provides an end-user interface that defines random variables following several standard distributions as well as some convenient interfaces for sampling them.

Usage

To use the system, you'll typically want import at least two modules: Data.Random for the main interface and a supported entropy source, such as System.Random.MWC from the mwc-random package. You may also want to import one or more of the extra distributions provided in the Data.Random.Distribution heirarchy (uniform and normal are exported by Data.Random automatically). Then, you can define random variables using do notation, sample them using sampleFrom, etc. For example:

import Data.Random
import System.Random.MWC (create)

logNormal :: Double -> Double -> RVar Double
logNormal mu sigmaSq = do
    x <- normal mu sigmaSq
    return (exp x)

main = do
    mwc <- create
    y <- sampleFrom mwc (logNormal 5 1)
    print y

Installation

Get the latest release from Hackage:

cabal install random-fu

Or a bleeding-edge version from github:

git clone https://github.com/mokus0/random-fu.git
cd random-fu
(cd random-source; cabal install)
(cd rvar;          cabal install)
(cd random-fu;     cabal install)

random-fu's People

Contributors

adscib avatar alexanderkjeldaas avatar bgamari avatar idontgetoutmuch avatar mnacamura avatar mokus0 avatar reinerp avatar zenzike avatar

Watchers

 avatar  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.