Exemple #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from numpy import *
from matplotlib import pylab
import stochbb

X1 = stochbb.gamma(3, 100) + 100
X2 = stochbb.gamma(3, 120) + 100
Y1 = stochbb.gamma(3, 140) + 100
Y2 = stochbb.gamma(3, 130) + 100

Z1 = stochbb.condchain(X1, X2, Y1, Y2)

Tmin, Tmax, steps = 0, 2000., 100
t = linspace(Tmin, Tmax, steps)

pX1 = zeros(steps, )
X1.density().eval(Tmin, Tmax, pX1)
pX2 = zeros(steps, )
X2.density().eval(Tmin, Tmax, pX2)
pY1 = zeros(steps, )
Y1.density().eval(Tmin, Tmax, pY1)
pY2 = zeros(steps, )
Y2.density().eval(Tmin, Tmax, pY2)
pZ1 = zeros(steps, )
Z1.density().eval(Tmin, Tmax, pZ1)

pylab.plot(t, pX1, label="X1")
pylab.plot(t, pX2, label="X2")
pylab.plot(t, pY1, label="Y1")
pylab.plot(t, pY2, label="Y2")
Exemple #2
0
#
# This example uses 3 Gamma distributions (of wich one is a shifted Gamma distribution) and the
# minimum(,) operator. For both conditions (control, experimental) there is a common stage C
# following some Gamma distribution. Under control condition, the common stage is followed by a
# second Gamma distributed stage X1 (C -> X1). Under the experimental condition, the common stage
# also triggers a second stage X2 with a shifted Gamma distribution parallel with the stage X1
# present under the control conditon. This stage is delayed by 300ms relative to the parallel stage
# X1, but completes much faster than X1 once it started. The response latency under the exp.
# condition is then the chain C -> max(X1, X2).
#

#
# Processing model
#
d = 300
C = stochbb.gamma(3,20)
X1 = stochbb.gamma(10,30)
# shifted gamma
X2 = stochbb.gamma(1,70) + d


# response latency control condition
#   is simply R = C + X1
Rc = C + X1
# and for the experimental condition
Re = C + stochbb.minimum(X1, X2)

Tmin, Tmax, N = 0, 1200, 1200;
t = linspace(Tmin, Tmax, N);
Tc = empty((N,)); Rc.density().eval(Tmin, Tmax, Tc)
Te = empty((N,)); Re.density().eval(Tmin, Tmax, Te)
from numpy import *
import stochbb
from matplotlib import pylab

Tmin, Tmax, N = 0, 700, 1000;
t = linspace(Tmin, Tmax, N)

stochbb.Logger.addHandler(stochbb.IOLogHandler())

X = stochbb.gamma(10,10);
Y = stochbb.gamma(10,20);
Z = X+Y+100;
print X.density().rangeEst(0.01)
print Y.density().rangeEst(0.01)
print Z.density().rangeEst(0.01)

dX = empty(N,); X.density().eval(Tmin, Tmax, dX);
dY = empty(N,); Y.density().eval(Tmin, Tmax, dY);
dZ = empty(N,); Z.density().eval(Tmin, Tmax, dZ);

pylab.plot(t, dX)
pylab.plot(t, dY)
pylab.plot(t, dZ)

pylab.show()

Exemple #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from numpy import *
from matplotlib import pylab
import stochbb

X1 = stochbb.gamma(3, 100) + 100;
X2 = stochbb.gamma(3, 120) + 100;
Y1 = stochbb.gamma(3, 140) + 100;
Y2 = stochbb.gamma(3, 130) + 100;

Z1 = stochbb.condchain(X1, X2, Y1, Y2)

Tmin, Tmax, steps = 0, 2000., 100
t = linspace(Tmin, Tmax, steps)

pX1 = zeros(steps,); X1.density().eval(Tmin, Tmax, pX1);
pX2 = zeros(steps,); X2.density().eval(Tmin, Tmax, pX2);
pY1 = zeros(steps,); Y1.density().eval(Tmin, Tmax, pY1);
pY2 = zeros(steps,); Y2.density().eval(Tmin, Tmax, pY2);
pZ1 = zeros(steps,); Z1.density().eval(Tmin, Tmax, pZ1);

pylab.plot(t, pX1, label="X1")
pylab.plot(t, pX2, label="X2")
pylab.plot(t, pY1, label="Y1")
pylab.plot(t, pY2, label="Y2")
pylab.plot(t, pZ1, label="Z1")
pylab.legend()

pylab.show()
Exemple #5
0
#
# This example uses 3 Gamma distributions (of wich one is a shifted Gamma distribution) and the
# minimum(,) operator. For both conditions (control, experimental) there is a common stage C
# following some Gamma distribution. Under control condition, the common stage is followed by a
# second Gamma distributed stage X1 (C -> X1). Under the experimental condition, the common stage
# also triggers a second stage X2 with a shifted Gamma distribution parallel with the stage X1
# present under the control conditon. This stage is delayed by 300ms relative to the parallel stage
# X1, but completes much faster than X1 once it started. The response latency under the exp.
# condition is then the chain C -> max(X1, X2).
#

#
# Processing model
#
d = 300
C = stochbb.gamma(3, 20)
X1 = stochbb.gamma(10, 30)
# shifted gamma
X2 = stochbb.gamma(1, 70) + d

# response latency control condition
#   is simply R = C + X1
Rc = C + X1
# and for the experimental condition
Re = C + stochbb.minimum(X1, X2)

Tmin, Tmax, N = 0, 1200, 1200
t = linspace(Tmin, Tmax, N)
Tc = empty((N, ))
Rc.density().eval(Tmin, Tmax, Tc)
Te = empty((N, ))
Exemple #6
0
#

# Log word frequency (per mililon)
#  is uniform distr. on the interval [0,4]
f = stochbb.uniform(0, 4)

# Predictability is unif. distributed on the interval [0,1]
#  somewhat unrealistic but this is just an example
p = stochbb.uniform(0, 1)

#
# Cognitive model
#

# "lexical" stage is gamma distributed with k=5*f+5, theta=10
L = stochbb.gamma(5 * f + 5, 10)
# "semantic" stage is gamma distributed with k=10*p+5, theta=20
S = stochbb.gamma(10 * p + 5, 20)
# motor stage, gamma distributed with k=10, theta=30
M = stochbb.gamma(10, 30)

# response latency is simply R = L + S + M
R = L + S + M

Tmin, Tmax, N = 0, 1200, 1000
t = linspace(Tmin, Tmax, N)
dt = float(Tmax - Tmin) / N
pL = empty(N, )
L.density().eval(Tmin, Tmax, pL)
pS = empty(N, )
S.density().eval(Tmin, Tmax, pS)
Exemple #7
0
from numpy import *
import stochbb
from matplotlib import pylab

X1 = stochbb.gamma(2,1.1)+1
X2 = stochbb.gamma(2,1)+1
X3 = X1 + X2

Tmin, Tmax, N = 0, 4, 100
t = linspace(Tmin, Tmax, N)
dX1 = empty((N,)); X1.density().eval(Tmin, Tmax, dX1)
dX2 = empty((N,)); X2.density().eval(Tmin, Tmax, dX2)
dX3 = empty((N,)); X3.density().eval(Tmin, Tmax, dX3)

pylab.plot(t, dX1, label="X1")
pylab.plot(t, dX2, label="X2")
pylab.plot(t, dX3, label="X1+X2")


Tmin, Tmax, N = 0, 12, 300
t = linspace(Tmin, Tmax, N)
dX12 = empty((N,)); X1.density().eval(Tmin, Tmax, dX12)
dX22 = empty((N,)); X2.density().eval(Tmin, Tmax, dX22)
dX32 = empty((N,)); X3.density().eval(Tmin, Tmax, dX32)

pylab.plot(t, dX12, "--", label="X1")
pylab.plot(t, dX22, "--", label="X2")
pylab.plot(t, dX32, "--", label="X1+X2")

pylab.legend()
pylab.show()
Exemple #8
0
from numpy import *
import stochbb
from matplotlib import pylab

Tmin, Tmax, N = 0, 700, 1000
t = linspace(Tmin, Tmax, N)

stochbb.Logger.addHandler(stochbb.IOLogHandler())

X = stochbb.gamma(10, 10)
Y = stochbb.gamma(10, 20)
Z = X + Y + 100
print X.density().rangeEst(0.01)
print Y.density().rangeEst(0.01)
print Z.density().rangeEst(0.01)

dX = empty(N, )
X.density().eval(Tmin, Tmax, dX)
dY = empty(N, )
Y.density().eval(Tmin, Tmax, dY)
dZ = empty(N, )
Z.density().eval(Tmin, Tmax, dZ)

pylab.plot(t, dX)
pylab.plot(t, dY)
pylab.plot(t, dZ)

pylab.show()
Exemple #9
0
#

# Log word frequency (per mililon)
#  is uniform distr. on the interval [0,4]
f = stochbb.uniform(0,4)

# Predictability is unif. distributed on the interval [0,1]
#  somewhat unrealistic but this is just an example
p = stochbb.uniform(0,1)

#
# Cognitive model
#

# "lexical" stage is gamma distributed with k=5*f+5, theta=10
L = stochbb.gamma(5*f+5, 10);
# "semantic" stage is gamma distributed with k=10*p+5, theta=20
S = stochbb.gamma(10*p+5, 20);
# motor stage, gamma distributed with k=10, theta=30
M = stochbb.gamma(10, 30)

# response latency is simply R = L + S + M
R = L+S+M

Tmin, Tmax, N = 0, 1200, 1000;
t = linspace(Tmin, Tmax, N); dt = float(Tmax-Tmin)/N
pL = empty(N,); L.density().eval(Tmin, Tmax, pL)
pS = empty(N,); S.density().eval(Tmin, Tmax, pS)
pM = empty(N,); M.density().eval(Tmin, Tmax, pM)
pR = empty(N,); cProfile.run("R.density().eval(Tmin, Tmax, pR)")
Exemple #10
0
from numpy import *
import stochbb
from matplotlib import pylab

X1 = stochbb.gamma(2, 1.1) + 1
X2 = stochbb.gamma(2, 1) + 1
X3 = X1 + X2

Tmin, Tmax, N = 0, 4, 100
t = linspace(Tmin, Tmax, N)
dX1 = empty((N, ))
X1.density().eval(Tmin, Tmax, dX1)
dX2 = empty((N, ))
X2.density().eval(Tmin, Tmax, dX2)
dX3 = empty((N, ))
X3.density().eval(Tmin, Tmax, dX3)

pylab.plot(t, dX1, label="X1")
pylab.plot(t, dX2, label="X2")
pylab.plot(t, dX3, label="X1+X2")

Tmin, Tmax, N = 0, 12, 300
t = linspace(Tmin, Tmax, N)
dX12 = empty((N, ))
X1.density().eval(Tmin, Tmax, dX12)
dX22 = empty((N, ))
X2.density().eval(Tmin, Tmax, dX22)
dX32 = empty((N, ))
X3.density().eval(Tmin, Tmax, dX32)

pylab.plot(t, dX12, "--", label="X1")