Solving Probability Project: Acceptable Error Rate?

In summary: Yes, it is unnecessary in this context since the focus is on the error rate and not the actual number of people who voted for each choice.
  • #1
magnifik
360
0
can anyone help me understand the following project specs? it is supposed to be relatively simply to code, but i can't even figure out what exactly I'm supposed to do.

there are 1000000 people choosing A or B. the process repeats 1000 times. 520000 chose A while 480000 chose B. but there was a 15% error in which B was mistaken for A or A was mistaken for B. is the 15% rate enough to make the results invalid? find the acceptable error rate.

this is what i have so far. I'm not sure how to take into account the error or number of people who actually choose A or B.
Code:
int main(){
	int A = 0;
	int B = 0;
	int aWins = 0;

	srand(time(0));
	for (int j = 0; j < 1000; j++){
	for (int i = 0; i < 1000000; i++){
		if ((rand()%2) == 0)
			B++;
		else
			A++;
	}
	if (A > B)
		aWins++;
	}
	cout << aWins << endl;
	cout << (double)(aWins*100)/1000<< endl;
}
 
Physics news on Phys.org
  • #2
You can introduce the swapping error into your code like so:

Code:
int main(){
	int A = 0;
	int B = 0;
	int aWins = 0;
        [B]int errorPercent = 15; // errorPercent% of the time, the comparison will be incorrect
[/B]
	srand(time(0));
	for (int j = 0; j < 1000; j++){
	for (int i = 0; i < 1000000; i++){
		if ((rand()%2) == 0)
                        [B]if( (rand()%100) + 1 > errorPercent )
			      B++;
                         else
                               A++;[/B]
		else
                        [B]if( (rand()%100) + 1 > errorPercent )
			      A++;
                         else
                              B++;[/B]
	}
	if (A > B)
		aWins++;
	}
	cout << aWins << endl;
	cout << (double)(aWins*100)/1000<< endl;
}

Though, I'm not sure how you could find what is being asked... seems kind of silly. Maybe you just compare different levels of swapping error until you see a large difference between no swapping error and that level of swapping error?
 
  • #3
just wondering.. why do you use (rand()%100) + 1?
 
Last edited:
  • #4
magnifik said:
just wondering.. why do you use (rand()%100) + 1?

rand()%100 + 1 returns a number from 1 to 100.
rand()%100 alone returns a number from 0 to 99.

We can examine a smaller example so we can work through the logic step by step:
rand()%3
A random integer has three possibilities: it is evenly divided by 3 (remainder 0), it has a remainder of 1 after division by 3, or it has a remainder of 2 after division by 3. Therefore, we see that rand()%n returns a number from 0 to n-1. Adding 1 brings this to a more "regular" range of 1 to n.

Then, in my code, I say that if a random number from 1 to 100 is greater than the error percent (15 in this case), then there is no swap. 16-100 are greater than that (which is exactly 85 numbers). 1 to 15 are below or equal to it (15 numbers). So we can see that the comparison yields true 85% of the time and false 15% of the time.
 
  • #5
so regardless of the percent error, you would still use rand()%100 + 1?
 
  • #6
magnifik said:
so regardless of the percent error, you would still use rand()%100 + 1?

Yes. The program will work for any realizable percent error (0-100). I haven't thought about how it behaves past 100% error or for negative percents, because that has no practical use here.
 
  • #7
is it unnecessary information to have the 520000 people who voted for A and the 480000 people who voted for B?
 

Related to Solving Probability Project: Acceptable Error Rate?

What is an acceptable error rate in probability?

An acceptable error rate in probability refers to the margin of error that is considered acceptable for a given experiment or study. It is the level of deviation from the expected or true value that is deemed acceptable in order to draw valid conclusions.

How is an acceptable error rate determined?

The determination of an acceptable error rate depends on various factors, such as the type of experiment or study, the level of confidence desired, and the level of risk involved. It is often determined through statistical analysis and can also be influenced by the specific goals and objectives of the project.

Why is it important to have an acceptable error rate in probability?

Having an acceptable error rate is crucial in ensuring the validity and reliability of research findings. It helps to minimize the chances of drawing incorrect conclusions and provides a measure of confidence in the results obtained.

What are some common methods for reducing the error rate in probability?

There are several methods for reducing the error rate in probability. These include increasing the sample size, using more precise measurement tools, conducting multiple trials, and using advanced statistical techniques such as regression analysis and control groups.

Can an error rate of 0% be achieved in probability?

In theory, an error rate of 0% is possible in probability. However, in practice, it is highly unlikely to achieve a perfect error rate due to the inherent uncertainty and variability in data. The goal is to minimize the error rate as much as possible while still maintaining a reasonable level of confidence in the results.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
23
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
Replies
10
Views
991
  • Programming and Computer Science
Replies
4
Views
691
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
Back
Top