diff --git a/py/brain2_playground.py b/py/brain2_playground.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/py/brain2_playground.py diff --git a/py/brain2_playground.py b/py/brain2_playground.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/py/brain2_playground.py diff --git a/py/poisson_generator.py b/py/poisson_generator.py index 48db27d..cbba848 100644 --- a/py/poisson_generator.py +++ b/py/poisson_generator.py @@ -2,6 +2,7 @@ import random from math import log import matplotlib.pyplot as plt +import numpy as np class PoissonProcess(): def __init__(self, **kwargs): @@ -25,13 +26,33 @@ print(poi) #matplotlib: x=index, y=poi[index] -plt.plot(range(100),poi) +plt.eventplot(poi) #2 (points) -import numpy as np -poi = np.random.poisson(5,100) -plt.plot(poi) +poi = np.random.poisson(5,size=100) +print(f"avergae is {np.average(poi)}") + +#poi = [i-j for i,j in zip(poi[:-1],poi[1:])] + +poi2 = [np.sum(poi[1:i]) for i in range(len(poi))] +print(poi2) +#poi = np.diff(poi) # alternative numpy solution for inter-interval durations +#plt.plot(poi2) plt.show() #%% + +import numpy as np +from scipy.special import factorial + +def events_prob(events_per_unit_time, total_time, num_of_events): + # poisson dist + lam = events_per_unit_time * total_time + return np.exp(-lam) * np.power(lam, num_of_events) * factorial(num_of_events) + + +rate = 5 +ks = np.arange(20) +ps = events_prob(5,20,ks) +print(np.argmax(ps), np.max(ps)) \ No newline at end of file