SkillAgentSearch skills...

Rounding

Stochastic Rounding

Install / Use

/learn @dmaust/Rounding
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

rounding

Rounding methods

StandardRound rounds to the nearest, and in the event of a tie, rounds up.

RoundToEven rounds to the nearest, but in the event of a tie, rounds toward the nearest even number.

StochasticRound provides a mechanism to eliminate accumulated roundoff error in the presence of a distribution where for individual samples, the roundoff error is skewed. This is typically caused by small values. This may be a common problem when dealing with applying a function to many small integer values as the number of discrete inputs is small.

One drawback to stochastic rounding is the output is non-deterministic, but this can be avoided by providing a custom deterministic generator, or invoking providing the random number generator with a fixed seed.

.. code:: python

r = random.Random() r.seed(123) sr = StochasticRound(precision=0, random_generator=r)

Related Skills

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated1y ago
Forks2

Languages

Python

Security Score

65/100

Audited on Jul 19, 2024

No findings