Giter Site home page Giter Site logo

pomma89 / troschuetz.random Goto Github PK

View Code? Open in Web Editor NEW
47.0 5.0 8.0 5.41 MB

Fully managed library providing various random number generators and distributions.

Home Page: https://gitlab.com/pomma89/troschuetz-random

random distributions generators mt19937 xorshift discrete-distributions continuous-distributions

troschuetz.random's People

Contributors

kasthack avatar pomma89 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

Watchers

 avatar  avatar  avatar  avatar  avatar

troschuetz.random's Issues

First Int is always 1

In the following scenario, results will always be { 0, 100000, 0, 0 }.

            var results = new int[4];
            for (int x = 0; x < 100000; x++)
            {
                var rnd = new TRandom();
                results[rnd.Next(4)]++;
            }

In the next scenario, results will be something like { 24971, 124881, 25068, 25080 }.

            var results = new int[4];
            for (int x = 0; x < 100000; x++)
            {
                var rnd = new TRandom();
                results[rnd.Next(4)]++;
                results[rnd.Next(4)]++;
            }

So the first roll is always 1. The second is sufficiently random.

Why are the uint and int functions opposite in terms of default bounds?

Looking at IGenerator, I see that Next() produces an int between 0, and int.MaxValue exclusive, and NextInclusiveMaxValue() is between 0 and int.MaxValue inclusive. Looking at the uint functions, I see the opposite: NextUInt() produces a value between 0 and uint.MaxValue inclusive, whereas NextUIntExclusiveMaxValue() produces a value between 0 and uint.MaxValue exclusive.

Why does NextUInt() default to an inclusive bound, whereas Next() defaults to an exclusive bound? At first glance it seems a little unintuitive -- I would expect that both would default to the same bounds behavior, if there is no reason to do otherwise.

MT19937 not as in Wikipedia?

I have implemented MT19937 in C# according to the code in wikipedia and wanted to verify results with your implementation, but they were wrong.
I narrowed it to the line
https://github.com/pomma89/Troschuetz.Random/blob/fe9423531c158ee01ad1d16515f186fb5d7ac9ca/src/Troschuetz.Random/Generators/MT19937Generator.cs#L353
It reduces random number range from 32 to 31 bits.

In wikipedia case it is

     y := y xor (y >> l)
     return lowest w bits of (y)

Notice it is "L" (18) not 1.
that I translated as

            y = y ^ (y >> l);
            return 0xffffffffU & y;

Notice that your results are also different from the online test

MIT License?!

I would like to use this library in a project that is under MIT. Do you think it would be feasible to change the license of Troschuetz.Random to MIT?

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.