seallard / walker

NEAT
MIT License
0 stars 0 forks source link

Testing probabilistic code #13

Closed seallard closed 4 years ago

seallard commented 4 years ago

How am I supposed to test code that depends on random variables?

seallard commented 4 years ago

Maybe extract randomness to wrapper functions? Sample the random variable outside the function and provide it as an argument. But some functions requires repeated random sampling... Provide a list of outcomes to function? This is nice, maybe pass function which samples a random variable as an argument? Then the tests can pass some non-random function

seallard commented 4 years ago

Another way would be to test the frequency of the outcomes and see if they match what is expected. But that feels super brittle and clunky. Or maybe not. But it does not seem like the best way in my case