-3

For some reason, I need to have a program that will make a small no. of mistakes every now and then, and I should not know what mistakes it has made and when.

I do not need it to make multiple mistakes in one set(run of the algorithm), but rather I plan on making (say) 10,000 runs of the program, and I need it to make mistakes 200 times ..

Very importantly, I must be sanguine that there are no more than (1/5)n mistakes, where n is the total no. of results generated using the program.

The results that I am talking about here can be anything that is quantifiable and verifiable, like eg. an array of values.

Doing something like this:

for(int i=0; i<10000; i++)
   //one fifth of the times put garbage in the array using random function!!
   for (int j=0; j<5; j++)
      array[j]=j;

is too simplistic and not real enough.

So I thought may be I must look for a mathematical function that can do this for me. Any ideas ?

P.S. I am a noob at math (struggled with engineering college math). So please elaborate your answer. Dont say something like "Use XXX'YYY theorem .." I might not understand! Also, plese attach proper taf to this question. I could not thing of any ..

Chani
  • 7,871
  • What do you mean by real enough? Maybe define a set of mistakes that you choose from-swap a pair of values in the array, change just one value in the array, change all the 0's in the array to 1's? – Ross Millikan Jan 10 '12 at 14:06
  • 1
    So, something like if (rand() < 0.2) then, then? – J. M. ain't a mathematician Jan 10 '12 at 14:07
  • @J.M. Sorry, cant use that. (I think this was clear enough from my code sample) – Chani Jan 10 '12 at 15:47
  • 5
    No, it wasn't; you haven't said anything about conditionals not being allowed. – J. M. ain't a mathematician Jan 10 '12 at 15:51
  • 2
    Are @RYUZAKI and drunkMonk the same person? –  Jan 10 '12 at 16:58
  • @RahulNarain yeah! Actually the machines at the company i work for are firewalled for social networking and gmail, yahoo, etc; so i have two accounts. – Chani Jan 10 '12 at 17:16
  • @RYUZAKI: would you like the two accounts merged? The merged accounts should (IIRC) keep both sets of log-in information, and you then should be able to log-in using an OpenID provider other than Facebook/Google etc. – Willie Wong Jan 12 '12 at 13:56
  • @WillieWong it would be awesome if you could merge the accounts with the option of multiple login credentials. Thanks a lot. P.S. Just make sure you preserve the Stackexchange credentials of [email protected] so that i can use this id and password to log into this account. Also, would this work for all SE sites or just this one ? – Chani Jan 13 '12 at 05:47
  • @RYUZAKI I just did the merge. It should propagate across all SE sites in your network. The login credentials lists now both the ones you used for RYUZAKI and drunkMonk, so it should work. If it somehow doesn't, please send an e-mail to [email protected] linking to this discussion here. – Willie Wong Jan 13 '12 at 11:12

1 Answers1

1

Sometimes a programming language will allow picking a (pseudo-)random item from a list. If you can the following pseudocode seems to do what you want:

  1. BigList is the complete list of the number of runs, say 10000.

  2. For $i$ = $1$ to $200$.

  3. Pick $n$ from BigList. (This uses the item picking function)

  4. Replace BigList with BigList $\smallsetminus \{ n \} $. (Delete $n$ from BigList)

  5. End For (At the end of the for loop we now know which runs should have an error.

  6. Do $i$ = $1$ to $10000$.

  7. If $i$ is still in BigList do the right thing, else do the wrong thing.

  8. End Do.

Jay
  • 3,822