Does this algorithm guarantee equaprobable outcomes?

  • Thread starter Bipolarity
  • Start date
  • Tags
    Algorithm
In summary, this conversation discusses a method for traversing a list of numbers and swapping elements based on a coin flip. The resulting number is not equiprobable, with the last number having a 50% probability. It is suggested to generate a random number instead for equaprobability.
  • #1
Bipolarity
776
2
Suppose you have a list of numbers, say ##{1, 7, 9, 4, 5, 6}##.
You store the first number, and then iterate through this list.
For each number in the list, you flip a coin. If it is heads, you swap that element in the list with the number you stored. If tails, you do nothing. Either way, you move on to the next number in the list.

When you finish traversing the list, the resulting number is the number you stored. I am curious if all numbers in the list are equaprobably to be the final stored number, and if this is indeed the case, how might one prove this?

Thanks!

BiP
 
Physics news on Phys.org
  • #2
No, the numbers are not equiprobable. The last number has a 50 % probability.
 
  • #3
Ah I see, I suppose then that each number has half the probability of its successor?

Also, do you think there might be a way for me to tweak this so that the numbers are indeed equaprobable? This is for an application I'm trying to build.

BiP
 
Last edited:
  • #4
Bipolarity said:
Ah I see, I suppose then that each number has half the probability of its successor?

Yes, apart from the first number which has the same.

Bipolarity said:
Also, do you think there might be a way for me to tweak this so that the numbers are indeed equaprobable? This is for an application I'm trying to build.
Yes, but the normal thing to do would be to simply generate a random number k between 1 and N, where N is the number of numbers you have and then select the kth number.
 
  • #5
Coin flips aren't equiprobable , are they ?

ETA: never mind, I see the thread already :P
 

1. What is an algorithm?

An algorithm is a set of instructions or rules that are followed to solve a problem or complete a task. It is a step-by-step process that is designed to produce a specific outcome.

2. What does it mean to guarantee equaprobable outcomes?

To guarantee equaprobable outcomes means that each possible outcome has an equal chance of occurring. In other words, all outcomes are equally likely to happen.

3. How can I determine if an algorithm guarantees equaprobable outcomes?

To determine if an algorithm guarantees equaprobable outcomes, you can look at the steps of the algorithm and make sure that each possible outcome is given the same chance of occurring. You can also test the algorithm multiple times and analyze the results to see if they are evenly distributed.

4. Why is it important for an algorithm to guarantee equaprobable outcomes?

It is important for an algorithm to guarantee equaprobable outcomes because it ensures fairness and unbiased results. If an algorithm does not guarantee equaprobable outcomes, certain outcomes may occur more frequently than others, leading to inaccurate or unfair results.

5. Are there any drawbacks to an algorithm guaranteeing equaprobable outcomes?

There can be drawbacks to an algorithm guaranteeing equaprobable outcomes, such as requiring more computational resources or taking longer to produce results. In some cases, it may also be difficult or impossible to guarantee equaprobable outcomes, depending on the complexity of the problem or task being solved.

Similar threads

  • Set Theory, Logic, Probability, Statistics
2
Replies
45
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
2K
  • Programming and Computer Science
Replies
17
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Math Proof Training and Practice
2
Replies
61
Views
6K
  • Set Theory, Logic, Probability, Statistics
Replies
15
Views
1K
  • Programming and Computer Science
Replies
7
Views
3K
Back
Top