Skip to content

Commit 0ecf712

Browse files
committed
Added test for normal_pdf
1 parent 89af056 commit 0ecf712

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/spikeinterface/core/tests/test_core_tools.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import platform
2+
import math
23
from multiprocessing.shared_memory import SharedMemory
34
from pathlib import Path
45
import importlib
@@ -10,6 +11,7 @@
1011
make_paths_relative,
1112
make_paths_absolute,
1213
check_paths_relative,
14+
normal_pdf,
1315
)
1416
from spikeinterface.core.binaryrecordingextractor import BinaryRecordingExtractor
1517
from spikeinterface.core.generate import NoiseGeneratorRecording
@@ -87,5 +89,21 @@ def test_path_utils_functions():
8789
assert check_paths_relative(d, r"\\host\share")
8890

8991

92+
def test_normal_pdf() -> None:
93+
mu = 4.160771
94+
sigma = 2.9334
95+
dx = 0.001
96+
97+
xaxis = np.arange(-15, 25, dx)
98+
gauss = normal_pdf(xaxis, mu=mu, sigma=sigma)
99+
100+
assert math.isclose(1.0, dx * np.sum(gauss)) # Checking that sum of pdf is 1
101+
assert math.isclose(mu, dx * np.sum(xaxis * gauss)) # Checking that mean is mu
102+
assert math.isclose(sigma**2, dx * np.sum(xaxis**2 * gauss) - mu**2) # Checking that variance is sigma^2
103+
104+
print(normal_pdf(-0.9355, mu=mu, sigma=sigma))
105+
assert math.isclose(normal_pdf(-0.9355, mu=mu, sigma=sigma), 0.03006929091)
106+
107+
90108
if __name__ == "__main__":
91109
test_path_utils_functions()

0 commit comments

Comments
 (0)