g0 = randn(1, 100);
g1 = g0;
g1(2:end) = flip(g1(2:end));
sprintf("%.15e", sum(g0) - sum(g1))
g0 = np.random.randn(100)
g1 = g0.copy()
g1[1:] = g1[1:][::-1]
print(sum(g0) - sum(g1))
In both Python and MATLAB, rerunning these commands enough times will repeat the following values (or their negatives; incomplete list):
8.881784197001252e-15
3.552713678800501e-15
2.6645352591003757e-15
4.440892098500626e-16
1.7763568394002505e-15
In fact, the first and second time I ran them - mat -> py -> mat -> py
- they were exactly same, making me think they share the RNG on system level with a delay... (but ignore this happened for the question).
I'll sooner fall through the floor than this coinciding, plus across different languages.
What's happening?
Windows 11
, Python 3.11.4
, numpy 1.24.4
, MATLAB 9.14.0.2286388 (R2023a) Update 3
,
Aucun commentaire:
Enregistrer un commentaire