Classical Mathematical Functions

These functions are primarily used to work with the Q# built-in data types Int, Double, and Range.

For example, the DrawCategorical operation has signature (Double[] => Int). It takes a categorical distribution specified by a list of probablities, such as an array of doubles as input, and returns a randomly-selected index into the array as an Int.

The probability of selecting a specific index is proportional to the value of the array element at that index. Array elements that are equal to zero are ignored and their indices are never returned. If any array element is less than zero, or if no array element is greater than zero, then the operation fails.