mercredi 31 août 2016

Strange Python output for counter loop

import numpy as np
    from numpy.random import randn
    N = 100000
    counter = 0
    for i in randn(N):
        if i < 1 and i > -1:
            counter = counter + 1
    counter/N

The code resulted in an output of ZERO everytime.

I changed the 100000 to 100000.0 and it gave me the 68% but informed me the following...

anaconda/lib/python2.7/site-packages/ipykernel/main.py:5: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future"

Can you help me figure out what is happening?




Aucun commentaire:

Enregistrer un commentaire