PySCeS / pysces

The official PySCeS project source code repository.
https://pysces.github.io
Other
34 stars 10 forks source link

random distribution support #19

Closed bgoli closed 7 years ago

bgoli commented 7 years ago

I've added support for functions from the Python random module in the random branch, this allows statements like: random.lognormvariate(2,1) random.uniform(1,3) to be used directly in the input file. This will also be useful for StochPy.

bgoli commented 7 years ago

I'll generate one or two test cases for this but otherwise it seems to be working

bgoli commented 7 years ago

OK I've refined this a bit so that only "simple" distributions can be used, here is an example of the distributions that I have implemented that can be used directly in the input file as random.*

randomfuncs

Here is an example input file to illustrated its use (an attempted SDE)

noisy_lin4.psc.txt

Example of a model using a random distribution

FIX: X0 X4 S3

R1: X0 = S1 (Vf1(X0/Ks1) - Vr1(S1/Kp1))/(1 + X0/Ks1 + S1/Kp1)

R2: S1 = S2 (Vf2(S1/Ks2) - Vr2(S2/Kp2))/(1 + S1/Ks2 + S2/Kp2)

R3: S2 = S3 random.gauss(S2, 0.1)

R4: S3 = X4 S3*lognormal

!F lognormal = random.lognormvariate(2,1)*0.1

InitEx

X0 = 10.0 X4 = 1.0

InitPar

lognormal = 0

Vf1 = 10.0 Vr1 = 1.0 Ks1 = 1.0 Kp1 = 1.0

Vf2 = 10.0 Vr2 = 1.0 Ks2 = 1.0 Kp2 = 1.0

Vf3 = 1.0 Ks3 = 1.0

InitVar

S1 = 1 S2 = 1 S3 = 1

end

bgoli commented 7 years ago

I've committed this to 0.9.5