How do I generate random letters in java based on probability?
问题 I am having trouble generating random letters based on probability. For example, the letters J, K, Q, Y, Z each have a probability of 1/96 of occurring. A similar process (with higher probabilities) is used for other letters. Can somebody show me how to do this? Edit to be specific: I'm writing a method called "getRandomLetter" that returns a char of a random letter based on a probability fraction. 回答1: The typical way to select from a discrete set of elements with specific probabilities is