Coder Social home page Coder Social logo

boyquotes / distrand Goto Github PK

View Code? Open in Web Editor NEW

This project forked from solargranulation/distrand

0.0 0.0 0.0 25 KB

A module for Godot engine to generate large amounts of random numbers with non-uniform distribution.

License: MIT License

C++ 98.63% Python 1.37%

distrand's Introduction

distrand

A Random Number Generation modules for users of Godot Engine.

Purpose

The goal of the project is to provide a convenient and efficient tool for generating random numbers with non-uniform distribution, which may then be used in games either through GDScript or by other modules. As a C++ modules it offers execution advantages over scripted solutions.

Using distrand

Types

Currently distrand exposes two object classes, RealNormal and IntNormal. Both create normal (or Gaussian) distributions of random numbers.

RealNormal generates random value floats and holds them in a RealArray.

IntNormal generates random value integers and holds them in an IntArray.

Public Methods

  • setparameters
  • generate
  • getvalue
  • getnext
  • getsingle

setparameters( mean , deviation )

Takes two values, type-matched to the variant (ints for IntNormal, floats for RealNormal), and sets the parameters for the next set of numbers to be generated if those parameters are valid. Erases any set of values previously generated in the object instance.

generate( count )

Where count is an integer. Generates count random values according to the normal distribution defined by stored parameters (mean and deviation).

getvalue( i )

Where i is an integer lesser than the count last generated. Returns the value of the random number in position i of the internal array. RealNormal returns a float while IntNormal returns an integer.

getnext()

Starting at the first element, sequentially returns each value resultant from the previous generation. If getvalue has been called it continues from there.

getsingle()

Generates and returns a new random number under the currently-defined curve.

GDScript Instantiation

RealNormal and IntNormal objects may be created like other objects in GDScript:

var foo=RealNormal.new()

To define and generate the distribution:

foo.normal(5.0, 1.5)

foo.generate(50000)

To access the data:

n = foo.getvalue(42)

n = foo.getnext()

Future features

  • Histogram-friendly data in Int* distributions, giving a count of each value.
  • Heart-cut and dog-food subsets of normal distributions.
  • Bi- and Multi-modal distributions.
  • Weibull distributions.

distrand's People

Contributors

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