Commit 65df02d7 authored by Reimar Leike's avatar Reimar Leike
Browse files

Fix complex sample variance

This fix is necessary to make samples consistent with the Hamiltonian. Fixing the variance this way makes np.std(s) of a samples s with variance 1 havyield sqrt(2) and not 1. However, this fix is more compatible with the definition of the complex Gaussian according to wikipedia, and compatible with the definition of the Fisher metric.
parent 09b704e4
Pipeline #76660 passed with stages
in 11 minutes and 52 seconds
......@@ -238,8 +238,8 @@ class Random(object):
raise TypeError("mean must not be complex for a real result field")
if np.issubdtype(dtype, np.complexfloating):
x = np.empty(shape, dtype=dtype)
x.real = _rng[-1].normal(mean.real, std*np.sqrt(0.5), shape)
x.imag = _rng[-1].normal(mean.imag, std*np.sqrt(0.5), shape)
x.real = _rng[-1].normal(mean.real, std, shape)
x.imag = _rng[-1].normal(mean.imag, std, shape)
x = _rng[-1].normal(mean, std, shape).astype(dtype, copy=False)
return x
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment