Giter VIP home page Giter VIP logo

fsrandom's Introduction

CircleCI

FsRandom

FsRandom is a purely-functional random number generator framework designed for F# language. It helps you to obtain a variety of random numbers to use more than ten predefined generators, and to define a new function to generate random numbers you want.

See the project home page for details.

Install

FsRandom can be installed from NuGet.

License

The 3-Clause BSD License

Maintainer(s)

The default maintainer account for projects under "fsprojects" is @fsprojectsgit - F# Community Project Incubation Space (repo management)

fsrandom's People

Contributors

chrsteinert avatar kos59125 avatar pocketberserker avatar teo-tsirpanis avatar wallymathieu 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fsrandom's Issues

Avoid multiple instantiation of RandomBuilder

The random builder is three to five times slower than raw PRNG functions. Performance tuning is desired.

A suspected cause is that each call creates a new instance of RandomBuilder; for instance, xorshift seed and RandomBuilder (xorshiftPrng, seed) are equivalent. RandomBuilder should take only Prng function to instantiate, and random seeds should be passed outside of random computation expression like the following code.

type RandomBuilder (prng : Prng<'s>) = ...
let random prng = RandomBuilder (prng)
let xorshift = random xorshiftPrng

let state = xorshift { return! ``[0, 1)`` }
let rec randoms initialSeed =
   seq {
      let u, nextSeed = run state initialSeed  // no instantiation
      yield u
      yield! randoms nextSeed
   }

Add operators

Computation expressions like draw ``[0, 1)`` into x?

Conversion of random number

Suppose we would like to obtain a random number on (0, 3).
uniform (0.0, 3.0) is not available because `uniform returns a random number on [0, 1].

So the current workflow may become as the following.

let triple x = 3.0 * x
let r, _ =
   xorshift seed {
      let! u = ``(0, 1)``
      return triple u
   }

And, the following code may be nicer.

let triple x = 3.0 * x
let r, _ = xorshift seed { return! getRandomBy triple ``(0, 1)`` }

Higher random number resolution

Two random numbers can generate one 53-bit resolution random number on [0, 1), (0, 1] or [0, 1], or one 52-bit resolution (0, 1).

Split modules

Functions like uniform and normal are statistical functions. They can be split into another module.

Seq module

Some of functions in Array module are availabe as seq<'a> instead of 'a [].

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.