Calculating Error Rate for Valid Results: A Wins Over 99.9% of the Time

  • Thread starter Thread starter magnifik
  • Start date Start date
  • Tags Tags
    Error Percent
Click For Summary

Discussion Overview

The discussion revolves around calculating the error rate necessary for a scenario where 999 out of 1000 results are valid, with one being invalid. Participants explore the implications of error rates in a program designed to determine the winner between two entities, A and B, based on their win counts. The conversation includes technical programming aspects and the logic behind error rates affecting outcomes.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant states that if there are 1000 valid results, then all must be valid, leading to confusion about the definition of valid and invalid results.
  • Another participant clarifies that they meant 999 results are valid and 1 is invalid, indicating a misunderstanding of the initial question.
  • Concerns are raised about the clarity of the problem being addressed, with requests for more specific details on what the participant is trying to solve.
  • A participant describes their code setup, where an error rate variable is used to determine whether the choices between A and B are swapped, and they express confusion about the output of their program.
  • There is a suggestion that the error rate should be treated as a constant rather than a loop counter, as the current implementation leads to an excessively high value.

Areas of Agreement / Disagreement

Participants express differing views on the clarity of the problem and the definitions of valid and invalid results. There is no consensus on the correct approach to calculating the error rate or the logic behind the code implementation.

Contextual Notes

Participants note limitations in the clarity of the problem statement and the assumptions made regarding the definitions of valid and invalid results. The discussion also highlights unresolved issues in the code logic that may affect the output.

magnifik
Messages
350
Reaction score
0
there are 1000 valid results, but 1 is invalid. in other words, 99.9% of the results are valid. what is the error rate for this to be possible?

basically right now i have these facts -- if A has more than B, A wins. in order for a result to be considered "valid," A must have more wins than B. below is a code with 15% error rate. my question is how do i find the error rate for the above restraints?

Code:
int main(){
	int A = 0;
	int B = 0;
	int aWins = 0;
        int errorPercent = 15; // errorPercent% of the time, the comparison will be incorrect

	srand(time(0));
	for (int j = 0; j < 1000; j++){
	for (int i = 0; i < 1000000; i++){
		if ((rand()%2) == 0)
                        if( (rand()%100) + 1 > errorPercent )
			      B++;
                         else
                               A++;
		else
                        if( (rand()%100) + 1 > errorPercent )
			      A++;
                         else
                              B++;
	}
	if (A > B)
		aWins++;
	}
 
Physics news on Phys.org
If you have 1000 valid results, then all one thousand of them are valid. There can't be any invalid results if all of them are valid results.

If you have 1000 results and one of them is invalid, then 99.9% of the results are valid.

What are you asking here? The only variable you have any control over is the errorPercent, so maybe you are supposed to try different values for this variable to see what happens.

You aren't being very clear on what you need to do, so if you want a better answer, you need to tell us exactly what problem you're trying to solve.
 
i meant of the 1000 results, 999 are valid, 1 is invalid. that's the problem I'm having...the specs aren't very specific
 
And your question isn't very clear. What's the problem you're trying to solve?

How do you know what result your program produces? There are no output statements.
 
this is what I'm trying to do right now. i have it set up where 1000000 choose either A or B. the errorRate variable dictates whether or not the choices were swapped. i have it set up so the errorRate gets incremented until A is less than B (because A is supposed to be greater than B in this game). however, when i try to run it... it just prints 1000000000. when i try to enter the errorRate manually, A is finally less than B around the errorRate of 42. what am i doing wrong in my code??

Code:
int errorRate = 0;
int A = 510000;
int B = 490000;
for (int z = 0; z < 1000; z++){
	for (int x = 0; x < 1000000; x++){
		if ((rand()%2) == 0){
			if ((rand()%100) + 1 <= errorRate){
				B--;
				A++;
			}
		}
		else{
			if ((rand()%100) + 1 <= errorRate){
				A--;
				B++;
			}
		}
	}
	errorRate++;
	if (A < B)
		break;
}
cout << errorRate << endl;
 
magnifik said:
this is what I'm trying to do right now. i have it set up where 1000000 choose either A or B. the errorRate variable dictates whether or not the choices were swapped. i have it set up so the errorRate gets incremented until A is less than B (because A is supposed to be greater than B in this game). however, when i try to run it... it just prints 1000000000. when i try to enter the errorRate manually, A is finally less than B around the errorRate of 42. what am i doing wrong in my code??

Code:
int errorRate = 0;
int A = 510000;
int B = 490000;
for (int z = 0; z < 1000; z++)
{
   for (int x = 0; x < 1000000; x++)
   {
       if ((rand()%2) == 0)
      {
         if ((rand()%100) + 1 <= errorRate)
         {
            B--;
            A++;
         }
      }
      else
      {
         if ((rand()%100) + 1 <= errorRate)
         {
            A--;
            B++;
         }
      }
   }
   errorRate++;
   if (A < B)
   break;
}
cout << errorRate << endl;

Each time the inner loop finishes an iteration, you increment errorRate (which starts at 0). By the time the outer loop is finished, errorRate will have been incremented to 1,000,000,000. No surprise there.

Instead of using errorRate as a glorified loop counter, I would suggest treating it as a constant that you set, and displaying something more useful, like A and B.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
8
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
6K