Skip to content
Snippets Groups Projects
Commit b0f59911 authored by Delvigne Frank's avatar Delvigne Frank
Browse files

Upload New File

parent 5aed5179
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 14 10:49:39 2024
@author: delvigne
"""
import numpy as np
import matplotlib.pyplot as plt
import random
X = [0]
Y = [0]
t = [0]
tend = 1000
Beta_1 = 1
alpha_1 = 0.2
Beta_2 = 1
alpha_2 = 0.2
K = 1 #Affinity constant
n = 9 #Hill coefficient
while t[-1] < tend:
props = [(K**n / (K**n + Y[-1]**n)) * Beta_1, alpha_1 * X[-1], \
(K**n / (K**n + X[-1]**n)) * Beta_2, alpha_2 * Y[-1]]
prop_sum = sum(props)
tau = np.random.exponential(scale=1/prop_sum)
t.append(t[-1] + tau)
rand = random.uniform(0,1)
# G1 production event
if rand * prop_sum <= props[0]:
X.append(X[-1] + 1)
Y.append(Y[-1])
# G1 decay event
elif rand * prop_sum > props[0] and rand * prop_sum <= sum(props[:2]):
X.append(X[-1] - 1)
Y.append(Y[-1])
# G2 production event
elif rand * prop_sum > sum(props[:2]) and rand * prop_sum <= sum(props[:3]):
X.append(X[-1])
Y.append(Y[-1] + 1)
# G2 decay event
elif rand * prop_sum > sum(props[:3]) and rand * prop_sum <= sum(props[:4]):
X.append(X[-1])
Y.append(Y[-1] - 1)
f, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False)
line1, = ax1.plot(t , X, color="b",label="X")
line2, = ax2.plot(t , Y, color="r",label="Y")
ax1.set_ylabel('X')
ax2.set_ylabel('Y')
ax2.set_xlabel('Time')
plt.show()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment