I have a below method which is called every one minute from background thread and that background thread keeps running always.
public void testMethod() {
// some other code
int value = new Random().nextInt(20 - 1 + 1) + 1;
if(value > 19) {
// this will print hello line
System.out.println("hello");
}
// some other code
}
Now as you can see I am printing hello if my value is greater than 19. My question is how should I say that hello line will be printed at this rate or it will printed this percentage of time so that people can understand this.
If somebody asks me at what frequency or rate hello line will be printed given my above method is called every 1 minute. What should I say?
This line int value = new Random().nextInt(20 - 1 + 1) + 1; will generate random number between $1$ and $20$ inclusive both.
In every minute the probability that it will print
hellois $\frac{1}{20}$ assuming that the "Random" is fair in JAVALet $A$ denote the event that it will print
helloper one minute so $\mathrm {P}[A]=\frac{|A|}{|\Omega|}=\frac{1}{20}$Therfore the rate is one
helloper $20$ minutes