Random::normal generates infinity

I’m trying to work out a bug in an oscillator. The oscillator introduces random slew to simulate analog generator. If I let it run for about an hour the slew factor variable (float) goes to infinity and the oscillator dies. I’ve narrowed it down to a single “-inf” value I receive from random::normal approximately once every hour. I can obviously work around this by identifying the condition, but was wondering if this is an expected behavior based on σ = 1 μ = 0?

1 Like

I had a look at random::normal() and by looking at this line

float radius = std::sqrt(-2.f * std::log(1.f - uniform()));

As uniform() return a value between [0.0 - 1.0] , if its return value produces exactly 1.0, the call to std::log() will return -inf and so will random::normal()

3 Likes

@23volts, thank you for your response. That is true, and I just noticed this too. This seems to be an artifact in random::normal and I believe is a bug. When random::normal is used in open evaluations, a single INF can go unnoticed, but if this value is part of a feedback, it can lock down a process. I’m a bit far from probability and statistics. Maybe @Vortico can assist in a resolution?

1 Like

Thanks, fixed random::uniform() as it was not supposed to be returning 1.f.

3 Likes