xidulu commented on issue #16638: [WIP] [Numpy] Add sampling method for 
bernoulli
URL: https://github.com/apache/incubator-mxnet/pull/16638#issuecomment-549897379
 
 
   Unit tests to be added,
   Correctness is briefly verified by hand.
   ```
   In [9]: (npx.random.bernoulli(prob=prob, size=(1000000, 10, 10)).mean(0) - 
prob).mean()
   Out[9]: array(-3.0148094e-05, ctx=gpu(0))
   
   In [10]: (npx.random.bernoulli(prob=prob, size=(1000000, 10, 10)).var(0) - 
prob * (1 - prob)).mean()
   Out[10]: array(-9.472111e-06, ctx=gpu(0))
   
   In [11]: logit = np.log(prob) - np.log(1 - prob)
   
   In [12]: (npx.random.bernoulli(logit=logit, size=(1000000, 10, 10)).mean(0) 
- prob).mean()
   Out[12]: array(-3.4588957e-05, ctx=gpu(0))
   
   In [13]: (npx.random.bernoulli(logit=logit, size=(1000000, 10, 10)).var(0) - 
prob * (1 - prob)).mean()
   Out[13]: array(1.1445168e-05, ctx=gpu(0))
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to