Interview Question 3: Random number generator with weights
Generate random numbers such that they follow certain needed pattern. For example out of 100 generated random numbers.
35% should be 5
20% should be 25
10% should be 123
35% should be 73
The naming is confusing. The set of output numbers is small. You are just creating numbers from a small set {5,25,123,73} but the sequence of output numbers is random or unpredictable.
Can you think of any application or test bench mechanism where such numbers are needed?