0

I am trying to compute product of Bernoullis. enter image description here

It is not a great idea to compute the product by brute force since it may underflow. What I did is to take the log and then take the exp. But there would be warning when I have np.log(0). So usually how should we compute such quantity? Thanks!

jack
  • 883
  • 2
  • 9
  • 21
  • What's theta and x? – Mad Physicist Mar 08 '17 at 01:35
  • Sorry, theta is the p in Bernoulli distribution and x_d are the variables taken on 0 and 1. In this case, we have D independent bernoullis. – jack Mar 08 '17 at 01:38
  • What size is D expected to be, order of magnitude? – Mad Physicist Mar 08 '17 at 01:43
  • D could be 1000, or even larger. The thing is since theta is between 0 and 1, it could be too small. Actually I wanted to use this based on the EM algorithm here http://blog.manfredas.com/expectation-maximization-tutorial/ Where we want to update the responsibility for each z. And we have to compute the product of bernoulli and divided it by sum of product of bernoullis, they are both very small numbers that could approach zero. – jack Mar 08 '17 at 01:48
  • 1
    You could split up the product into the regular portions away from 0 and 1, and the log portions that are close to zero and one. If you are getting a warning about zero in the product, there is a problem because the whole thing will just be zero. – Mad Physicist Mar 08 '17 at 01:54
  • It would help to understand the actual problem you are trying to solve. – miraculixx Mar 08 '17 at 04:07

0 Answers0