Write a floating point random value to an output stream.
This routine is used for floating point random value printing. This routine writes
17 significant digits, the range available in doubles. This routine prefers decimal
format, without exponents. It will generate somewhat large precision numbers,
currently up to 28 digits, before switching to exponents.
The primary reason for this approach is to enable faster sorting on random values
by GNU sort and similar external sorting programs. GNU sort is dramatically faster
on decimal format numeric sorts ('n' switch) than general numeric sorts ('g' switch).
The 'general numeric' handles exponential notation. The difference is 5-10x.
Random values generated by Bernoulli sampling are nearly always greater than 1e-12.
No examples less than 1e-09 were seen in hundred of millions of trials. Similar
results were seen with weighted sampling with integer weights. The same is not true
with floating point weights. These produce quite large exponents. However, even
for floating point weights this can be useful. For random weights [0,1] less than 5%
will be less than 1e-12 and use exponential notation.
Write a floating point random value to an output stream.
This routine is used for floating point random value printing. This routine writes 17 significant digits, the range available in doubles. This routine prefers decimal format, without exponents. It will generate somewhat large precision numbers, currently up to 28 digits, before switching to exponents.
The primary reason for this approach is to enable faster sorting on random values by GNU sort and similar external sorting programs. GNU sort is dramatically faster on decimal format numeric sorts ('n' switch) than general numeric sorts ('g' switch). The 'general numeric' handles exponential notation. The difference is 5-10x.
Random values generated by Bernoulli sampling are nearly always greater than 1e-12. No examples less than 1e-09 were seen in hundred of millions of trials. Similar results were seen with weighted sampling with integer weights. The same is not true with floating point weights. These produce quite large exponents. However, even for floating point weights this can be useful. For random weights [0,1] less than 5% will be less than 1e-12 and use exponential notation.