# powering a probability [a Bernoulli factory tale]

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**R – Xi'an's Og**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**S**tarting from an X validated question on finding an unbiased estimator of an integral raised to a non-integer power, I came across a somewhat interesting Bernoulli factory solution! Thanks to Peter Occil’s encyclopedic record of cases, pointing out to Mendo’s (2019) solution for functions of ρ that can be expressed as power series. Like ρ^{γ} since

which rather magically turns into the reported algorithm

Set k=1 Repeat the following process, until it returns a value x: 1. Generate a Bernoulli B(ϱ) variate z; if z=1, return x=1 2. Else, with probability γ/k, return x=0 3. Else, set k=k+1 and return to 1.

since

To

**leave a comment**for the author, please follow the link and comment on their blog:**R – Xi'an's Og**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.