Package random_distributions

This module provides functionality to generate random numbers with arbitrary distributions. More...


Classes

class  XYResponseCurve
 Similar to ResponseCurve, but allows sample points to be unevenly spaced. More...
class  ResponseCurve
 This class is described in AI Programming Wisdom 1, "The Beauty of Response Curves", by Bob Alexander. More...
class  NormalisedInputCurve
class  Distribution2D
 This is a callable class that generates random numbers with an arbitrary distribution. More...

Functions

def lerp
 Linear interpolation, with clamping for inputs outside the range.
def sigmoid
 This function is a "soft" version of lerp.
def ramp
 The same as lerp, except that the output is extrapolated, not clamped when the input is higher than the maximum.
def line
 The same as lerp, except that output is linearly extrapolated when the input falls outside the range on both ends.
def make_distribution_curve
 Makes a distribution curve from input and output samples.
def distribution_from_grid

Variables

int newSampleCount = 1000
float THRESHOLD = 0.001


Detailed Description

This module provides functionality to generate random numbers with arbitrary distributions.

See:

Author:
Herman Tulleken (herman.tulleken@gmail.com)


Function Documentation

def random_distributions.distribution_from_grid (   grid,
  x_cells,
  y_cells 
)

Definition at line 308 of file random_distributions.py.

def random_distributions.lerp (   value,
  inputMin,
  inputMax,
  outputMin,
  outputMax 
)

Linear interpolation, with clamping for inputs outside the range.

This function can also be used for linear extrapolation. Compare with ramp and

Definition at line 29 of file random_distributions.py.

def random_distributions.line (   value,
  inputMin,
  inputMax,
  outputMin,
  outputMax 
)

The same as lerp, except that output is linearly extrapolated when the input falls outside the range on both ends.

Definition at line 52 of file random_distributions.py.

def random_distributions.make_distribution_curve (   inputSamples,
  outputSamples 
)

Makes a distribution curve from input and output samples.

The inputSamples denote boundaries, and the outputSamples denote the relative probabilities that a point is between those boundaries. Let x_0..x_{n-1} denote the inputs, and y_0..y_{n-1} be the outputs. Then y_i gives the relative probability that a point will be selected from the range [x_{i-1}, x_i). y_0 should be 0.

Definition at line 216 of file random_distributions.py.

def random_distributions.ramp (   value,
  inputMin,
  inputMax,
  outputMin,
  outputMax 
)

The same as lerp, except that the output is extrapolated, not clamped when the input is higher than the maximum.

The output is still clamped when the input fals below the inputMin.

Definition at line 44 of file random_distributions.py.

def random_distributions.sigmoid (   value,
  inputMin,
  inputMax,
  outputMin,
  outputMax 
)

This function is a "soft" version of lerp.

Definition at line 36 of file random_distributions.py.


Variable Documentation

Definition at line 23 of file random_distributions.py.

Definition at line 24 of file random_distributions.py.


Generated on Sun May 24 21:48:22 2009 by  doxygen 1.5.8