I am trying to generate a random number that only populates a certain percent of the time. For example, I want to create an array that is set between a certain range (lets say 0-100), but 10% of the time I want the random number chosen to be multiplied by n. How would I be able to generate this “random” number n% of the time?
edit
I haven’t tried it yet in Java, I’ve only been trying to write out the algorithm by hand but I am just getting stumped. What I am going to have is a variable that holds a number, lets say that number is 3000, and the random number from the array is going to be deducted out of the number 3000 until it hits 0, but a certain percent of the time I want the number pulled from the array to be multiplied by n a certain percent of the time .
You can do something 10% of the time by picking a random number between 0 and 100 and triggering the event if the number is less than 10. So, pick your random number. Then choose another random number between 0 and 100 and if that second number is less than 10, you multiply the first by n.