title: How to calculate the probability of a given character in a string using slices of this string?
body: <p>Given a string, such as <code>01001010101001101011</code>, we can randomly sliced multiple substrings. Assume that during the slicing, due to some unexpected noises, some characters may flip(<code>0-&gt;1</code> or <code>1-&gt;0</code>).  For example:</p>
  
  <pre><code>Position: 0123456789.........
  String:   01001010101001101011
  
  slice1:    1001110101000
  slice2:       1010111001111
  slice3:       10101
  slice4:                1101011
  </code></pre>
  
  <p><code>slice1</code> starts from position 1(assume that the index of a string begins with 0), <code>slice2</code> starts from position 4, <code>slice3</code> starts from 4, and <code>slice4</code> starts from 13. In <code>slice1</code>, <code>0</code> flips to <code>1</code> at position 5 and <code>1</code> flips to <code>0</code> at position 13.</p>
  
  <p>For one specific position in the original string, if it is <code>1</code>, then the probability of flipping to <code>0</code> in a slicing is 0.1; and vice versa(i.e.<code>Prob(0-&gt;1)=0.1</code>). </p>
  
  <p>The problem is: <strong>if we only have multiple slices(the length of each slice may vary) and their starting positions in the string, and we don't know the original string, given an arbitrary position in the original string, how can we calculate the probability that position is a <code>1</code>?</strong></p>
  
  <p>Assume most positions will be covered at least once in slices, and we have following parameters:</p>
  
  <pre><code>p01=0.1; // Probability a ‘0’ in string but flipped to a ‘1’ in a slice
  p10=0.1; // Probability a ‘1’ in string but flipped to a ‘0’ in a slice
  p1=0.5;  // Prior probability that any given position in string is a ‘1’
  </code></pre>
  
  <p>We can also assume that the string is a random string of 0s and 1s, and during slicing, each position is sampled independently. </p>
  
  <p>For the above example string and four slices, we already have following probabilities for each position:</p>
  
  <pre><code>Pos Prob
  0   0.500
  1   0.900
  2   0.100
  3   0.100
  4   0.999
  5   0.100
  6   0.999
  7   0.001
  8   0.999
  9   0.500
  10  0.988
  11  0.012
  12  0.012
  13  0.900
  14  0.988
  15  0.500
  16  0.988
  17  0.100
  18  0.900
  19  0.900
  </code></pre>
  
  <p>I spent hours trying to figure out how to get above answers, and I can count the numbers of <code>0</code>s and <code>1</code>s in all slices for each position with a program. However, I still cannot find a <strong>formula</strong> or <strong>model</strong> or <strong>algorithm</strong> to calculate the probabilities, especially for positions 4(<code>1,1,1</code>), 5(<code>1,0,0</code>), 9(<code>0,1</code>), 13(<code>0,1,1</code>).</p>