def Bernoulli_cosh(x):
'''
Sample according to 1/cosh(x/f)
Extends corollary 6.4 from BLISS paper
'''
powx = abs(x)
while(True):
A = Bernoulli_exp(powx) # each iteration this changes as randomness comes from Bernoulli_exp exp(-|x|/f)
if(A):
return 1
B = Bernoulli_rv(0.5) or Bernoulli_exp(powx) # has to be seperate Bernoulli_exp(powx) call as we dont want dependence on A
if not(B):
return 0
Gaussian_sampling.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录