LotkaVolterra:
Filter:
Classes (extension) | UGens > Generators > Chaotic

LotkaVolterra : MultiOutUGen : UGen : AbstractFunction : Object
ExtensionExtension

2-species Predator-Prey model
Source: PredPrey.sc

Description

UGen implementing 4th order Runge-Kutta approximation of the Lotka and Volterras Predator-Prey model:

x' = x * (a - b * y)
y' = y * (c * x - d)

Implemented by Till Bovermann inspired by Gary William Flake's Book "The Computational Beauty of Nature". Implementation following on Lance Putnam's chaos UGens and MCLDs ChaosUGens.

http://tai-studio.org

Class Methods

LotkaVolterra.categories

LotkaVolterra.ar(freq: 22050, a: 1.5, b: 1.5, c: 0.5, d: 1.5, h: 0.05, xi: 1, yi: 0.2, mul: 1, add: 0)

Arguments:

freq

update frequency, best set to Nyquist frequency. To modulate tonal qualities, use h.

a

meta-parameter, useful between 0 and 5; must not be negative.

b

meta-parameter, useful between 0 and 5; must not be negative.

c

meta-parameter, useful between 0 and 5; must not be negative.

d

meta-parameter, useful between 0 and 5; must not be negative.

h

step size for the approximation

xi

initial value for x, resets the UGen when changed

yi

initial value for y, resets the UGen when changed

mul

multiply withthis

add

add that

LotkaVolterra.equation

returns

x' = x * (a - b * y)
y' = y * (c * x - d)

Inherited class methods

Instance Methods

Inherited instance methods

Examples

// scope signals, set graphics to 'xy' to see relations between predator (out 0) and prey (out 1)
{LotkaVolterra.ar(SampleRate.ir*0.5, \a.kr(1.5, 0.1), \b.kr(1.5, 0.1), \c.kr(0.5, 0.1), \d.kr(1.5, 0.1), h: \h.kr(0.01), xi: 0.1 + \tr.tr(1))}.scope;
(
Ndef(\lv).addSpec(\freq, [0.1, 24000, \exp]);
Ndef(\lv).addSpec(\h, [0.01, 1, \exp]);
Ndef(\lv).addSpec(\which, [0, 2, \lin]);
Ndef(\lv).addSpec(\a, [0.01, 5, \lin]);
Ndef(\lv).addSpec(\b, [0.01, 5, \lin]);
Ndef(\lv).addSpec(\c, [0.01, 5, \lin]);
Ndef(\lv).addSpec(\d, [0.01, 5, \lin]);

Ndef(\lv, {
    LeakDC.ar(
        LotkaVolterra.ar(SampleRate.ir*0.5, \a.kr(1.5, 0.1), \b.kr(1.5, 0.1), \c.kr(0.5, 0.1), \d.kr(1.5, 0.1), h: \h.kr(0.01), xi: 0.1 + \tr.tr(1)) * 0.2
    ).tanh + 1 * LFPar.ar([100, 150]);
});
)


(
Ndef(\lv, {
    Mix(
        LeakDC.ar(
            LotkaVolterra.ar(SampleRate.ir*0.5,
                a: {LFNoise2.ar(Rand(0.000174, 0.00174)).range(0.49, 0.5)}!3,
                b: \b.kr(1.5, 0.1),
                c: {LFNoise2.ar(Rand(0.000174, 0.00174)).range(2, 4)}!4, // \c.kr(0.5, 0.1),
                a: {LFNoise2.ar(Rand(0.000174, 0.00174)).range(0.4, 0.41)}!4,
                h: \h.kr(0.01).lag2(1) * [0.5, 1, 2, 4],
                xi: 0.1 + \tr.tr(1)) * 0.2
        ) * [5, 3, 3, 1].normalizeSum;
    ).tanh
});

)

Ndef(\lv).set(\tr, 0.1)

Ndef(\lv).set(\a, 3.029850, \b, 4.094132, \c, 1.967217, \d, 2.295942);



Ndef(\lv).scope

Ndef(\lv).edit