+10 XP

Common Distributions in Neuroscience

NumPy has a whole module of random number generators. The most common in neuroscience:

python
import numpy as np

# Poisson: discrete spike counts
spikes = np.random.poisson(lam=20, size=100)  # 100 samples from Poisson(20)

# Normal (Gaussian): continuous values (voltages, currents, signals)
voltage_noise = np.random.normal(loc=-70, scale=5, size=100)  # mean -70, std 5

# Uniform: random values in a range
input_currents = np.random.uniform(low=0, high=2, size=100)  # random current 0-2 nA

# Exponential: intervals between events (waiting times until next spike)
inter_spike_intervals = np.random.exponential(scale=50, size=100)  # mean 50 ms

print(f'Poisson mean: {spikes.mean()}')
print(f'Normal mean: {voltage_noise.mean():.1f}, std: {voltage_noise.std():.1f}')
print(f'Uniform mean: {input_currents.mean():.1f} (should be 1.0)')

These are the four distributions you'll see constantly in NMA.

Always check: np.random.seed(42) at the start if you want reproducible randomness. With the same seed, you get the same 'random' numbers every time.