objective c - Algorithm to decide if true based on 0% - 100% frequency threshold -
Sorry, this is a duplicate question. I did a search but I was not sure what to really find.
I am writing an app that scans one, when the scan is completed we need to decide whether an item is found or not. Whether the items are not found, the threshold is determined by the user which can set: 0% of the time, 25% of the time, 50% of the time, 75% of time or 100% of the time.
Obviously, if the user chooses 0% or 100% then we can use true / false but for the frequency but I am painting on an empty space how it works for other thresholds. should do.
I think that every time I get a monster I need to store and raise some values.
Thanks for any help in advance! As <@
As @nix points, as you would like, a random number and threshold based on the percentage of that time Want to generate, when you want 'get something' '
You need to be careful that the range you select and the way you get desired Threshold, along with the result, also use the distribution of random number generator. While working in percentages, a clear perspective is to generate 100 to 1 equally distributed options and thresholds to generate them properly. 0-99 and check that your percentage is less than that number.
A quick check shows that you will not get less than 0 numbers, 0% gets the expected results, you will always get a number, less than 100% get the expected result And less than 50 choices (0-49) out of 100 options (0-99) are low, so 50% also get the expected results.
A A different approach than the above, given that users can choose categories in only 25% increase, numbers must be generated in the range 0-3 and if the number is less than percent / 25, Then it will be right. If you select as a number from the user- 0-4 (0: 0%, 1: 25% .. 4: 100%) it can also be easier.
In Objective-C, various methods of pseudo random number generation have been discussed here.
Note that the uniformity of the random number is probably mentioned when it is sensitive to the extent on which you go along.
Always do something simple, by calling several times by calling your work, testing to move forward, keeps track of the number of times when it gets right and compares the desired percentage.
Comments
Post a Comment