How to get the Cumulative Distribution Function for Gaussian Distribution

Hello, I would like to use the Cumulative Distribution Function for Gaussian Distribution.

I know it can be get it as:

fn = lambda x : torch.nn.GELU()(x) / x

But I am afraid it is not numerical stable. Any other suggestions? Thanks!

distributions/normal.py has it:

        return 0.5 * (1 + torch.erf((value - self.loc) * self.scale.reciprocal() / math.sqrt(2)))
1 Like