initial commit with 2024 materials

This commit is contained in:
Pamela Hathway 2025-09-19 10:46:45 +02:00
commit 6fdfdbb8b7
66 changed files with 102457 additions and 0 deletions

View file

@ -0,0 +1,22 @@
from math import isclose
import numpy
def test_var_deterministic():
x = numpy.array([-2.0, 2.0])
expected = 4.0
assert isclose(numpy.var(x), expected)
def test_var_fuzzing():
rand_state = numpy.random.RandomState(8393)
N, D = 100000, 5
# Goal variances: [0.1 , 0.45, 0.8 , 1.15, 1.5]
expected = numpy.linspace(0.1, 1.5, D)
# Generate random, D-dimensional data
x = rand_state.randn(N, D) * numpy.sqrt(expected)
variance = numpy.var(x, axis=0)
numpy.testing.assert_allclose(variance, expected, rtol=1e-2)