mercredi 8 juillet 2015

Unpredictable poisson noise

I'm in the process of comparing two sets of values for which I apply poisson noise. Below is my code and the corresponding result:

import numpy as np
import pylab

size = 14000

# 1) Creating first array
np.random.seed(1)
sample = np.zeros((size),dtype="int")+1000
# Applying poisson noise
random_sample1 = np.random.poisson(sample)

# 2) Creating the second array (with some changed values)
# Update some of the value to 2000...
for x in range(size):
  if not(x%220):
    sample[x]=2000
# Reset the seed to the SAME as for the first array
# so that poisson shall rely on same random.
np.random.seed(1)
# Applying poisson noise
random_sample2 = np.random.poisson(sample)

# Display diff result
pylab.plot(random_sample2-random_sample1)
pylab.show()

poisson_pb

My question is: why does I have this strange values around [10335-12542] where I would expect just a perfect zero?

I search for info in poisson() documentation without success.

I (only) test and reproduce the problem in python version 1.7.6 and 1.7.9 (It may appear on others). Numpy version tested: 1.6.2 and 1.9.2




Aucun commentaire:

Enregistrer un commentaire