วิธีสร้าง Bernoulli ต่อเนื่องไม่สำเร็จเป็นจำนวนเท่าใด?


18

ได้รับ:

  1. เหรียญกับที่ไม่รู้จักอคติp (หัวหน้า)
  2. บวกอย่างเคร่งครัดจริง > 0a>0

ปัญหา:

สร้างตัวแปร Bernoulli สุ่มที่มีอคติpa

ไม่มีใครรู้วิธีการทำเช่นนี้? ตัวอย่างเช่นเมื่อเป็นจำนวนเต็มบวกแล้วหนึ่งสามารถพลิกเหรียญครั้งและดูว่าผลลัพธ์ทั้งหมดเป็นหัว: ถ้าพวกเขาอยู่แล้วปัญหา '0' มิฉะนั้นปัญหา '1' ความยากลำบากอยู่ในความจริงที่ว่าไม่จำเป็นต้องเป็นจำนวนเต็ม นอกจากนี้ถ้าฉันรู้อคติpฉันก็สามารถสร้างเหรียญอื่นด้วยอคติที่ต้องการ aaap


2
@ gung: ฉันคิดว่าสิ่งที่ต้องการคืออัลกอริทึมในการสร้างตัวแปร Bernoulli ที่ได้รับเหรียญ
— Neil G

1
ผมคิดว่าจุดที่นี่คือเมื่อ> 1คุณเพียง แต่ให้ค่าเฉลี่ยของ 1 ออกจากทุกหัวที่ปรากฏขึ้นและเมื่อ< 1คุณซ้ำกันแต่ละหัวเฉลี่ยของ1 /ครั้ง a>1aa<11/a
— มาโคร

3
@Macro คุณสามารถขยายความคิดได้หรือไม่?
— Pedro A. Ortega

1
เรียนโดรส์ (+1) สำหรับโพสต์ของคุณซึ่งเป็นคำถามที่ทำให้ CV มีชีวิตชีวาและเร้าใจอย่างน้อยสำหรับฉัน ฉันขอถามว่าต้นกำเนิดของคำถามนี้คืออะไร?
— พระคาร์ดินัล

@cardinal: ขอบคุณอีกครั้งสำหรับคำตอบของคุณ! ปัญหานี้เป็นส่วนหนึ่งของตัวอย่างสำหรับการแก้ปัญหาการควบคุมสุ่มที่ฉันกำลังทำงานอยู่ เหตุผลที่pไม่เป็นที่รู้จักก็เพราะมันจะต้องรู้ค่าคงตัว normalizing (ซึ่งในกรณีนี้คือฟังก์ชั่นพาร์ทิชันที่น่ารังเกียจ) แต่เรายังสามารถสุ่มตัวอย่างจากมันโดยใช้การสุ่มตัวอย่างการปฏิเสธ Btw มันคงจะดีถ้าคุณอ้างอิงชื่อไม่ใช่แค่ลิงค์ไปยัง CV ;-)
— Pedro A. Ortega

คำตอบ:


19

เราสามารถแก้ปัญหานี้ได้ด้วย "ลูกเล่น" และคณิตศาสตร์เล็กน้อย

นี่คืออัลกอริทึมพื้นฐาน:

  1. สร้างตัวแปรสุ่มเรขาคณิตที่มีความน่าจะเป็นของความสำเร็จของพีp
  2. ผลของตัวแปรสุ่มนี้จะกำหนดค่าที่รู้จักกันคงfn∈[0,1] ]
  3. สร้างตัวแปรสุ่มBer(fn)โดยใช้การโยนเหรียญยุติธรรมที่สร้างขึ้นจากการพลิกคู่ที่ถูกบล็อกคู่ของเหรียญBer(p)
  4. ผลที่เกิดจะเป็นBer(pa)สำหรับการใด ๆ∈ ( 0 , 1 )ซึ่งเป็นสิ่งที่เราต้องการa∈(0,1)

เพื่อให้สิ่งต่าง ๆ ย่อยง่ายขึ้นเราจะแบ่งข้าวของออกเป็นชิ้น ๆ

ชิ้นส่วนที่ 1 : โดยไม่ต้องสูญเสียของทั่วไปคิดว่า0<a<1 1

หาก≥ 1แล้วเราสามารถเขียนหน้า = P n P ขสำหรับบางจำนวนเต็มบวกnและบาง0 ≤ ข< 1 แต่สำหรับ Bernoulli สองคนที่เป็นอิสระเรามี P ( X 1 = X 2 = 1 ) = p 1 p 2a≥1pa=pnpbn0≤b<1

P(X1=X2=1)=p1p2.
เราสามารถสร้างpn Bernoulli จากเหรียญของเราได้อย่างชัดเจน ดังนั้นเราต้องกังวลเท่านั้นตัวเองด้วยการสร้างBer(pa)เมื่อ ∈ ( 0 , 1 )a∈(0,1)

ชิ้นที่ 2 : รู้วิธีการสร้างโดยพลBer(q)จากพลิกเหรียญยุติธรรม

มีวิธีมาตรฐานในการทำเช่นนี้ ขยายในการขยายตัวไบนารีแล้วใช้เหรียญที่เหมาะสมของเราที่จะพลิก "จับคู่" ตัวเลขของคิว นัดแรกกำหนดว่าเราประกาศความสำเร็จ ("หัว") หรือล้มเหลว ("ก้อย") ถ้า q n = 1และการพลิกเหรียญของเราคือหัวประกาศหัวถ้า q n = 0และการพลิกเหรียญของเราคือก้อยให้ประกาศก้อย มิฉะนั้นให้พิจารณาตัวเลขที่ตามมากับการพลิกเหรียญใหม่q=0.q1q2q3…qqn=1qn=0

ส่วนที่ 3 : รู้วิธีสร้างเหรียญที่ยุติธรรมจากผู้ไม่ยุติธรรมที่มีอคติไม่ทราบ

สิ่งนี้เสร็จสิ้นสมมติว่าโดยการโยนเหรียญเป็นคู่ ถ้าเราได้รับ H Tให้ประกาศหัว หากเราได้รับ T Hให้ประกาศก้อยและทำซ้ำการทดลองจนกว่าจะมีผลลัพธ์หนึ่งในสองข้อดังกล่าวเกิดขึ้น พวกเขามีความน่าจะเป็นอย่างเท่าเทียมกันดังนั้นจะต้องมีความน่าจะเป็น 1 / 2p∈(0,1)HTTH1/2

ส่วนที่ 4 : คณิตศาสตร์บางอย่าง (เทย์เลอร์เพื่อช่วยเหลือ)

ด้วยการขยายประมาณp 0 = 1ทฤษฎีบทของเทย์เลอร์ยืนยันว่า p a = 1 - a ( 1 - p ) - a ( 1 - a )h(p)=pap0=1 โปรดทราบว่าเนื่องจาก 0 < a < 1แต่ละเทอมหลังจากเทอมแรกเป็นลบเราจึงมี p a = 1 - ∞ ∑ n = 1 b n ( 1 - p ) n

pa=1−a(1−p)−a(1−a)2!(1−p)2−a(1−a)(2−a)3!(1−p)3⋯.
0<a<1 ที่ 0 ≤ ขn ≤ 1เป็นที่รู้จักกันเบื้องต้น ดังนั้น 1 - p a = ∞ ∑ n = 1 b n ( 1 - p ) n = ∞ ∑ n = 1 b n P ( G ≥ n ) = ∞ ∑ n = 1 f n P ( G = n ) = E
pa=1−∑n=1∞bn(1−p)n,
0≤bn≤1 ที่ G ~ จีอีo เมตร (
1−pa=∑n=1∞bn(1−p)n=∑n=1∞bnP(G≥n)=∑n=1∞fnP(G=n)=Ef(G),
,ฉ0 = 0และฉn = Σ n k = 1ขkสำหรับ n ≥ 1G∼Geom(p)f0=0fn=∑k=1nbkn≥1

และเรารู้อยู่แล้วว่าวิธีการใช้เหรียญของเราในการสร้างตัวแปรสุ่มเรขาคณิตที่มีความน่าจะเป็นของความสำเร็จของพีp

ส่วนที่ 5 : เคล็ดลับ Monte Carlo

ให้เป็นตัวแปรสุ่มต่อเนื่องการค่าใน[ 0 , 1 ]ด้วยP ( X = x n ) = P n Let U | X ~ B อีอาร์ ( X ) แล้ว P ( U = 1 ) = Σ n x n P nX[0,1]P(X=xn)=pnU∣X∼Ber(X)

P(U=1)=∑nxnpn.

แต่เมื่อใช้และx n = f nเราจะเห็นวิธีสร้างB e r ( 1 - p a)pn=p(1−p)nxn=fnตัวแปรสุ่ม )และนี่เป็นการเทียบเท่ากับการสร้าง B e r ( p ก )หนึ่งBer(1−pa)Ber(pa)


ฉันจะอ้างอิงคุณ (หรือวิธีแก้ปัญหาของคุณ) ได้อย่างไร?
— Pedro A. Ortega

2
@Pedro: ฉันคิดว่าคุณสามารถคลิกที่ลิงก์ "แบ่งปัน" ที่ด้านล่างของคำตอบนี้ มันควรจะเป็นลิงค์ที่มั่นคง Math.SE มีกลไกการอ้างอิงซึ่งดูเหมือนว่าจะไม่เปิดใช้งานบนไซต์นี้ แต่คุณอาจสามารถปรับเปลี่ยนได้
— พระคาร์ดินัล

1
ตอนนี้เป็นคำตอบที่ยอดเยี่ยม!
— เซน

1
ฉันเขียนสิ่งนี้ขึ้นในฟอรัมการสนทนาทั่วไปของคลาส Coursera บนเครื่องวิเคราะห์เชิง Combinatorics เนื่องจากนี่เป็นการใช้ชุดไฟที่เกี่ยวข้องกับวัสดุบางอย่างที่ครอบคลุม class.coursera.org/introACpartI-001/forum/thread?thread_id=108
— Douglas Zare

@ ดักลาส: ขอบคุณ! มีรุ่นที่สามารถดูได้แบบสาธารณะหรือฉันจะต้องลงทะเบียนสำหรับหลักสูตรเพื่อดู? เปโดรกับฉันได้พูดคุยเกี่ยวกับลู่ทาง (ทางอีเมล) ที่เป็นไปได้สำหรับการรวมวิธีการนี้ไว้ในการวิจัยของเขา
— พระคาร์ดินัล

6

คำตอบต่อไปนี้โง่หรือเปล่า?

ถ้าเป็นอิสระB e r ( p )และY nมีการกระจายB e r ( ( ∑ n i = 1 X i / n ) a )จากนั้นY nจะถูกกระจายโดยประมาณเป็นB e r ( p a )X1,…,XnBer(p)YnBer((∑i=1nXi/n)a)YnBer(pa)เมื่อ ∞n→∞

ดังนั้นหากคุณไม่รู้จักแต่คุณสามารถโยนเหรียญนี้ได้หลายครั้งคุณสามารถสุ่มตัวอย่าง (โดยประมาณ) จากB epตัวแปรสุ่ม r ( p a )Ber(pa)

Rรหัสตัวอย่าง:

n <- 1000000
p <- 1/3 # works for any 0 <= p <= 1
a <- 4
x <- rbinom(n, 1, p)
y <- rbinom(n, 1, mean(x)^a)
cat("p^a =", p^a, "\n")
cat("est =", mean(y))

ผล:

p^a = 0.01234568 
est = 0.012291 

2
ฉันชอบคำตอบนี้ แต่ฉันสงสัยว่ามันพลาดจุดของคำถามซึ่งฉันตีความว่าเป็นการขออัลกอริทึมที่สร้างจากการกระจายที่ร้องขอโดยไม่ทราบว่า (หรือข้อมูลเชิงประจักษ์เกี่ยวกับp ) แต่ปัญหาที่เกิดขึ้นไม่ส่อว่าคุณสามารถสร้างB E R n o ยูลิตรลิตรฉัน ( P )ตัวแปรสุ่มดังนั้นนี้เป็นคำตอบที่สมบูรณ์เหมาะสมและไม่ได้โง่ที่ทุกคน! +1ppBernoulli(p)
— มาโคร

1
+1: ฉันชอบมัน ฉันคิดว่าคุณหมายถึงกระจาย…? Yn
— Neil G

ดีกว่ามาก! Tks, @Neil G!
— เซน

1
นี่คือสิ่งที่น่ารัก (+1) แต่เราสามารถทำได้ในจำนวน จำกัด ที่แน่นอน (และโดยเฉลี่ยแล้วจำนวนนั้นจะค่อนข้างเล็ก)
— พระคาร์ดินัล

5

ฉันโพสต์คำอธิบายต่อไปนี้ของคำถามนี้และคำตอบของพระคาร์ดินัลต่อฟอรัมสนทนาทั่วไปของคลาส Analytic Combinatorics ปัจจุบันใน Coursera "การประยุกต์ใช้ชุดพลังงานเพื่อสร้างตัวแปรสุ่ม" ฉันโพสต์สำเนาไว้ที่นี่เป็นวิกิชุมชนเพื่อเผยแพร่ต่อสาธารณะและถาวรมากขึ้น


มีคำถามและคำตอบที่น่าสนใจใน stat.stackexchange.com ที่เกี่ยวข้องกับซีรีย์พาวเวอร์: "จะสร้างความสำเร็จของเบอร์นูลลีต่อเนื่องได้อย่างไร?" ฉันจะถอดความคำถามและคำตอบโดยที่สำคัญ

สมมติว่าเรามีเหรียญอาจจะไม่เป็นธรรมซึ่งเป็นหัวด้วยความน่าจะและเป็นบวกจำนวนจริงα เราจะสร้างเหตุการณ์ที่มีความน่าจะเป็นp αได้อย่างไรpαpα

ααα1/20<α<1p3.5p3p0.5 0.5

p′∈[0,1]HT1TH as 0, and ignoring HH and TT. We compare this stream with the binary expansion of p′=0.a1a2a3...2. The event that the first disagreement is where ai=1 has probability p′. We don't know pα, so we can't use this directly, but it will be a useful tool.

The main idea is that we would like to use the power series for pα=(1−q)α=1−αq−α(1−α)2q2−α(1−α)(2−α)3!q3−... where p=1−q. We can construct events whose probabilities are qn by flipping the coin n times and seeing if they are all tails, and we can produce an event with probability p′qn by comparing the binary digits of p′ with a fair bit stream as above and checking whether n tosses are all tails.

Construct a geometric random variable G with parameter p. This is the number of tails before the first head in an infinite sequence of coin tosses. P(G=n)=(1−p)np=qnp. (Some people use a definition which differs by 1.)

Given a sequence t0,t1,t2,..., we can produce tG: Flip the coin until the first head, and if there are G tails before the first head, take the element of the sequence of index G. If each tn∈[0,1], we can compare tG with a uniform random variable in [0,1] (constructed as above) to get an event with probability E[tG]=∑ntnP(G=n)=∑ntnqnp.

This is almost what we need. We would like to eliminate that p to use the power series for pα in q.

1=p+qp+q2p+q3p+...

qn=qnp+qn+1p+qn+2p+...

∑nsnqn=∑nsn(qnp+qn+1p+qn+2p+...)=∑n(s0+s1+...+sn)qnp

Consider 1−pα=αq+α(1−α)2q2+.... Let tn be the sum of the coefficients of q through qn. Then 1−pα=∑ntnqnp. Each tn∈[0,1] since the coefficients are positive and sum to 1−0α=1, so we can construct an event with probability 1−pα by comparing a fair bit stream with the binary expansion of tG. The complement has probability pα as required.


Again, the argument is due to cardinal.


1
(+1) Thanks for going to the trouble to post this. The differences in exposition, while relatively slight, help make the approach more clear.
— cardinal

4

The very complete answer by cardinal and subsequent contributions inspired the following remark/variant.

Let PZ stand "Probability of Zero" and q:=1−p. If Xn is an iid Bernoulli sequence with PZ q, then Mn:=max(X1,X2,…,Xn) is a Bernoulli r.v. with PZ qn. Now making n random i.e., replacing it by an integer rv N≥1 leads to Bernoulli rv MN with

Pr{MN=0}=∑n=1∞Pr{MN=0|N=n}Pr{N=n}=∑n=1∞Pr{N=n}qn.
So if 0<a<1 and if we take Pr{N=n}=bn from cardinal's answer, we find Pr{MN=0}=1−pa and 1−MN is Ber(pa) as wanted. This is indeed possible since the coefficients bn satisfy bn⩾0 and they sum to 1.

The discrete distribution of N depends only on a with 0<a<1, recall

Pr{N=n}=an∏k=1n−1(1−a/k)(n≥1).
It has interesting features. It turns out to have an infinite expectation and an heavy tail behaviour nbn∼c/na with c=−1/Γ(−a)>0.

Though MN is the maximum of N rvs, its determination needs a number of Xk which is ≤N since the result is known as soon as one Xk is 1. The number of computed Xk is geometrically distributed.


A related idea would be to make the rvs Xk dependent with extremal index θ (0<θ<1), meaning that Mn has PZ qnθ rather than qn. Taking nθ=a would do the job for any a>0. Given a sequence of iid rv.s Xn following a standard Frechet, there are known methods to generate a dependent sequence Xn⋆ with standard Frechet margin and the prescribed extremal index θ. However, what happens if we replace standard Frechet'' by Bernoulli''?
— Yves

(+1) Very nice, @Yves. A few remarks: (1) The first part can be viewed as the complement of the approach I've taken. In fact, when I first got the series in bnqn, while I immediately saw the connection to the geometric, I first tried something more direct and didn't come up with a natural way to do it. Your answer solves that problem. (2) Your approach can also be implemented using only a Ber(p) coin. In particular, N can be generated by descending down a full binary tree based on fair coin flips, where the left nodes are leaves and the decision is made by (...)
— cardinal

(...) comparing the number in (0,1) constructed from the (partial) sequence of coin flips to the partial sums fn=∑i=1nbi. The termination depth gives N. (3) I believe that nbn∼cn−(1+a), which will change your conclusion regarding the finiteness of the mean. (4) In both your approach and mine, it seems we cannot escape computing fn=∑i=1nbi, even if we allow for uniform random variates in addition to our Ber(p) coin for the purposes of sampling. Finding a way to avoid that would seem to be the most obvious way to improve efficiency.
— cardinal

1
Thank you @cardinal. I agree with all your comments except perhaps (3). I actually made an error since c is −1/Γ(−a) (edited), but the exponent of n seems the right one. I used the representation of Γ(z) as found e.g. on Wikipedia page on infinite product and took z:=−a which gives an equivalent for the product ∏k=1n−1. I would be more confident if you could check this.
— Yves

Dear @Yves, (+1) You are correct about the constant and about (3). My apologies. Somehow, when I went to transcribe things to paper, I ended up focusing on the asymptotics of bn instead of nbn. :-)
— cardinal
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.