StatBalStream:
Filter:
BBCut/Classes (extension) | Libraries > BBCut > Cut procedures

StatBalStream
ExtensionExtension

Stream class implementing Charles Ames' method of statistical feedback

Charles Ames' statistical feedback is a type of weighted random number generator that is useful for generating streams of random numbers that sound more "natural" and "balanced." Statistical balance keeps track of the distributions of its own output and compensates for short-term lack of diversity. A "heterogeneity" parameter allows you to control how strong this compensation is -- low heterogeneity approaches deterministic behavior (like serialism) and high heterogeneity behaves more randomly.

The pseudocode is as follows:

W, h, and a can all be changed during the generator's evolution.

References (all Ames, Charles):

Class Methods

.new

Arguments:

states

An array of the states to return

weights

An array of weightings, one for each state. Weights may be zero.

heterogeneity

any positive float. Whilst weightings will be approached in the long term, how quickly this occurs relative to serialism and the tolerance within which a running histogram of results fluctuates depends on the ratio of heterogeneity to accent (by default 1).

Heterogeneity 0.0 gives fully deterministic results, like serialism. Increasing heterogeneity increases the shuffling of order of appearance of states, that is, less predictability in the short term.

If heterogenity is really large then floating point problems will eventually occur.

length

Number of calls to next before returning nil for sequence end. Default is inf for forever.

Instance Methods

.next

Get the next state.

.reset

Restart the stream.

.accent

Sets the accent parameter as described in the above pseudocode. The default is 1.

.stats

The internal statistics vector (S in the above pseudocode).

Examples