probability wheel, redistribution of probabilities

I have a contiguous ordered data structure (0 based index):

````x= [1/3, 1/3, 1/3]
````

Let's say I selected index 1 and increased the probability by 1/3. Rest of the probabilities each decrease by 1/6 and the total probability remains P = 1.

````x= [1/6, 2/3, 1/6]
````

Let's say I selected index 2 and increased the probability by 1/3. Rest of the probabilities in total need to decrease by 1/3 to make the total probability remain P= 1.

````x= [1/10, 2/5, 1/2]
````

Is there a name for this kind of data structure? I'd like to research that name and use a library instead of my custom rolled code if possible.

-

1 Answer

This can be easily achieved by an array $A$ and an additional variable $m$. The entry $A[i]$ stores the probability of $i$ times $m$.

````A=[1,1,1], m=3
````

The you increase the probability of the second element by 1/3. This can be carried out by setting $A[2]=4$ and $m=6$, which gives

````A=[1,4,1], m=6
````

In general you could set the probability of element $k$ to $p$ by solving the system $$\sum_i A[i] = m \text{ and } A[k]=p\cdot m,$$ for the unknowns $A[k]$ and $m$.

So all you need to do is to set $m$ to $$m = \frac{\sum_{i\neq k} A[i]}{1-p},$$ and $A[k]=p\cdot m$ for the new $m$.

-

@pwned: yepp. Fixed it. – A.Schulz Nov 18 '12 at 20:08
@ASchulz I see where this is going, I will profile this compared to my auto normalizing version. In the meanwhile, would you help me find a data structure similar to this? I know this isn't about how memory is laid out, but it supports all the operations a data structure would have. (mutation of elements, growth, etc) It's about probability distributions and histograms or roulette wheel, or maybe it doesn't exist and I'm making something new. I just need some more keywords. – pwned Nov 18 '12 at 21:08
@pwnd: I suggest your post you request as new question and give all the details. Describe precisely what set of operations  should be supported and what are your other requirements. – A.Schulz Nov 19 '12 at 9:02
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 14, "mathjax_display_tex": 2, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9376220703125, "perplexity_flag": "middle"}