3 ms·
np.random itself with that configuration can go negative with a probability of 0.62% as can be derived with scipy.stats.norm(loc = 7500, scale = 3000).cdf(0) or
by mxmlnkn 3y ago
np.random itself with that configuration can go negative with a probability of 0.62% as can be derived with scipy.stats.norm(loc = 7500, scale = 3000).cdf(0) or by looping a million times and counting the negative numbers.
Maybe the f2d function filters negative values but it sounds like a simple float-to-double conversion.
I'm not sure whether it was intentional, but, contrary to the headline, this random value was used to update the fund size daily as shown in the rest of the code. So, a single day for which the fund actually decreases wouldn't matter much. It might even be beneficial to make it look more real.
- BXlnt2EachOther 3y agof2d does seem like float-to-decimal (edit, typo). My brain is off for the evening but might that part have a misplaced parenthesis? They f2d() the random number but then multiply it by the higher-precision expression (previous day's volume / 1 billion), which will give 8 numbers after the decimal in USD as in the tweet they posted. Still, it's fewer digits than without the call I suppose.