Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is numpy.random.binomial(1, nan) = -9223372036854775807?

Tags:

python

nan

numpy

As in the title, I would expect it to be a nan as well. Is this number special?

like image 341
capybaralet Avatar asked Mar 30 '14 16:03

capybaralet


1 Answers

This is clearly a bug in numpy.ramdom.binomial.

Is this number special?

I would guess this is the result of some calculation involving the raw representation of nan (which is represented as a specific "reserved" float value). (More on that)

The implementor probably forgot to check input for nan and included the raw representation of nan in the (C-level) calculation.

like image 89
shx2 Avatar answered Nov 15 '22 08:11

shx2