[Numpy-discussion] PR 8053 np.random.multinomial tolerance param

Stephan Hoyer shoyer at gmail.com
Mon Sep 26 14:59:00 EDT 2016


I would actually be just as happy to relax the tolerance here to 1e-8
always. I doubt this would catch any fewer bugs than the current default.
In contrast, adding new parameters adds cognitive overload for everyone
encountering the function.

Also, for your use case note that tensorflow has it's own function for
generating random values from a multinomial distribution:
https://www.tensorflow.org/versions/r0.10/api_docs/python/constant_op.html#multinomial

On Mon, Sep 26, 2016 at 11:52 AM, Alex Beloi <a.beloi at samsung.com> wrote:

> Hello,
>
>
>
> Pull Request: https://github.com/numpy/numpy/pull/8053
>
>
>
> I would like to expose a tolerance parameter for the function
> numpy.random.multinomial.
>
>
>
> The function `multinomial(n, pvals, size=None)` correctly raises exception
> when `sum(pvals) > 1 + 1e-12` as these values should sum to 1. However,
> other libraries often cannot or do not guarantee such level of precision.
>
>
>
> Specifically, I have encountered issues with tensorflow function
> tf.nn.softmax, which is expected to output a tensor whose values sum to 1,
> but often with precision of only 1e-8.
>
>
>
> I propose to expose the `1e-12` tolerance to a non-negative float
> parameter with default value `1e-12`.
>
>
>
> Alex
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160926/e608eb04/attachment.html>


More information about the NumPy-Discussion mailing list