1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Round off random_normal() test results one more decimal place.

As I suspected, some machines have even more low-order-bit
inaccuracy than the ones I tested.  Tweak new test so that
(hopefully) it will pass everywhere.  Per buildfarm.

Discussion: https://postgr.es/m/4173840.1673290336@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2023-01-09 22:44:16 -05:00
parent f745739697
commit 02d552c4f4
2 changed files with 26 additions and 26 deletions

View File

@ -113,34 +113,34 @@ SELECT random() FROM generate_series(1, 10);
-- Likewise for random_normal(); however, since its implementation relies -- Likewise for random_normal(); however, since its implementation relies
-- on libm functions that have different roundoff behaviors on different -- on libm functions that have different roundoff behaviors on different
-- machines, we have to round off the results a bit to get consistent output. -- machines, we have to round off the results a bit to get consistent output.
SET extra_float_digits = 0; SET extra_float_digits = -1;
SELECT random_normal() FROM generate_series(1, 10); SELECT random_normal() FROM generate_series(1, 10);
random_normal random_normal
-------------------- -------------------
0.208534644938377 0.20853464493838
0.264530240540963 0.26453024054096
-0.606752467900428 -0.60675246790043
0.825799427852654 0.82579942785265
1.70111611735357 1.7011161173536
-0.223445463716189 -0.22344546371619
0.249712419190998 0.249712419191
-1.2494722990669 -1.2494722990669
0.125627152043677 0.12562715204368
0.475391614544013 0.47539161454401
(10 rows) (10 rows)
SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10); SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10);
r r
------------------- ------------------
1.00605972811732 1.0060597281173
1.09685453015002 1.09685453015
1.02869206132007 1.0286920613201
0.909475676712336 0.90947567671234
0.983724763134265 0.98372476313426
0.939344549577623 0.93934454957762
1.18713500206363 1.1871350020636
0.962257684292933 0.96225768429293
0.914441206800407 0.91444120680041
0.964031055575433 0.96403105557543
(10 rows) (10 rows)

View File

@ -79,7 +79,7 @@ SELECT random() FROM generate_series(1, 10);
-- Likewise for random_normal(); however, since its implementation relies -- Likewise for random_normal(); however, since its implementation relies
-- on libm functions that have different roundoff behaviors on different -- on libm functions that have different roundoff behaviors on different
-- machines, we have to round off the results a bit to get consistent output. -- machines, we have to round off the results a bit to get consistent output.
SET extra_float_digits = 0; SET extra_float_digits = -1;
SELECT random_normal() FROM generate_series(1, 10); SELECT random_normal() FROM generate_series(1, 10);
SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10); SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10);