简体   繁体   English

不公平硬币跳过清单

[英]Skip list with unfair coin

So I've been studying skip lists in school and we briefly spoke about if we were to use an 'unfair coin' in a skip list rather than a fair coin, (example: probability of the unfair coin flip resulting in a value of "Heads" is set to p where 0 < p < 1 (so that the probability of "Tails" is 1 −p). 因此,我在学校里研究了跳过清单,我们简短地谈到了如果要在跳过清单中使用“不公平硬币”而不是公平硬币,(例如:不公平硬币翻转的概率导致“ “头”设置为p,其中0 <p <1(因此,“尾巴”的概率为1 -p)。

There are a few things I've wondered about this that I don't really understand as we passed over the topic so quickly. 当我们如此迅速地通过话题时,我对此有些疑惑,但我对此并不太了解。

  1. What would happen to the height/size of a skip list if we did this? 如果我们这样做,跳过列表的高度/大小会怎样? It would obviously change things if the probability was skewed, right? 如果概率不正确,那显然会改变事情,对吗? Say it contained arbitrary n elements, obviously the heights would be different than if we used a fair coin. 假设它包含任意n个元素,显然高度与使用公平硬币的高度不同。

  2. How would the expected number of promotions that would be received by an arbitrary node when adding it to the skip list change? 将任意节点添加到跳过列表时,预期将收到的促销数量如何变化? I don't know if it would in this scenario but it was a topic of discussion. 我不知道这种情况是否会发生,但这是讨论的话题。

I'm not looking for someone to just give answers without me actually understanding, but if you could actually explain why these changes are happening so that I can understand how it is being affected by a change in probability, I would appreciate it. 我不是要有人在没有我真正理解的情况下给出答案,但是如果您能真正解释为什么会发生这些变化,以便让我能够理解它受到概率变化的影响,我将不胜感激。

EDIT: I think I now understand after doing some comparisons of different probabilities with the equation provided on page 99 of Pat Morin's Open Data Structures book. 编辑:我想在用Pat Morin的《开放数据结构》一书第99页提供的方程式对不同概率进行一些比较之后,我现在可以理解。 I'll post my solution in the comments once I figure it out in order to help others with the same question. 一旦找到解决方案,我就会在评论中发布我的解决方案,以帮助其他有相同问题的人。

You can look up the answers to your questions here: https://en.wikipedia.org/wiki/Skip_list#Description 您可以在此处查找问题的答案: https : //en.wikipedia.org/wiki/Skip_list#Description
I will try to explain them: 我将尝试解释它们:
Let p be the probability for an element to be promoted to the next level, then 令p为将元素提升到下一个级别的概率,则

  1. the height will be log 1/p n . 高度将为log 1 / p n
    Reason: 原因:
    In the last row 0 we have n elements. 在最后一行0中,我们有n个元素。 As every element has the probability of p to appear in the next higher row, we have n * p elements in row 1. With the same arguing we will get n * p 2 elements in line 2. As you can see we have n * p x elements in row x . 由于每个元素都有p出现在下一较高行中的可能性,因此在第1行中有n * p个元素。通过相同的争论,我们将在2行中获得n * p 2个元素。如您所见,我们有n *xp X [元素。
    The highest row will have 1 item, so we get the equation 1 = n * p x and solving this for x we get x = log 1/p n ( x = log 2 n for a fair coin). 最高的行有1个项目,因此我们得到等式1 = n * p x ,对于x求解它,我们得到x = log 1 / p n (对于公平硬币, x = log 2 n )。
  2. each element will appear in 1/(1-p) lists on average. 每个元素平均会出现在1 /(1-p)列表中。
    Reason: 原因:
    The chance of only appearing in one list is (1 - p) (chance of promotion is p ). 仅出现在一个列表中的机会是(1-p) (晋升的机会是p )。
    The chance of making it to the second but not the third list is p * (1 - p) (promoted once [ p ] and not on the second coin flip [ 1-p ]). 进入第二个而不是第三个列表的机会是p *(1- p) (提升一次[ p ]而不是第二次掷硬币[ 1-p ])。
    Second but not third p 2 * (1 - p) and so on 第二个但不是第三个p 2 *(1- p)等等
    In general: 一般来说:
    p x-1 * (1-p) for being in x lists. p x-1 *(1-p)表示在x列表中。
    For the expected value of lists an element appears in we have: 对于列表的期望值,出现一个元素:
    exp = 1 * (1-p) + 2 * p * (1-p) + 3 * p 2 * (1-p) ... exp = 1 *(1-p)+ 2 * p *(1-p)+ 3 * p 2 *(1-p)...
    = ∑ i=0 (i+1) * p i * (1-p) =ΣI = 0∞第(i + 1)* P I *(1-p)的
    = (1-p) * ∑ i=0 (1+i) * p i =(1-p)* ∑ i = 0∞ (1 + i)* p i
    = (1-p) * 1/(1-p) 2 =(1-p)* 1 /(1-p) 2
    = 1/(1-p) = 1 /(1-p)
    Proof for the elimination of the sum to 1/(1-p) 2 can be found here: https://en.wikipedia.org/wiki/Geometric_series#Geometric_power_series 可以在以下位置找到将和消除为(1 /(1-p) 2 )的证明: https : //en.wikipedia.org/wiki/Geometric_series#Geometric_power_series

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM