SpeQ has functions for probability calculations and for generating random numbers.
Probability theory has to do with uncertainty in occurrences.
|
| Function | Description |
|---|---|
| Factorial(x) x! |
Factorial of x.
The factorial of a natural number x is the product of all positive integers less than and equal to x.
For example 5! = 5*4*3*2*1 = 120.
SpeQ can also calculate the factorial value for positive, non-integer values. |
| nPr(n, r) | The number of possibilities for choosing an ordered set of r objects (a permutation) from a total of n objects. Definition: nPr(n,r) = n! / (n-r)! |
| nCr(n, r) | The number of different, unordered combinations of r objects from a set of n objects. Definition: nCr(n,r) = nPr(n,r) / r! |
| Rand | Returns a random value between 0 and 1. |
| Rand({min, } max) | If both min and max are given, the function returns a random value (decimal) between min and max. If only max is given the function returns a random value between 0 and max. |
| RandInt({min, } max) | If both min and max are given, the function returns a random number (integer) between min and max. If only max is given the function returns a random number between 0 and max. |
'Examples of using Probability functions
'There are nPr(26, 4) possible ways to write a word with 4 distinct letters.
nPr(26, 4)
Ans = 358800
'This is equal to:
26*25*24*23
Ans = 358800
'In the example above there are combinations with the same 4 letters
'but a different order. For example the groups "hgcb" and "bghc". To
'find the number of different combinations we can use the function nCr.
nCr(26, 4)
Ans = 14950
'Probability of winning Lotto (6 numbers from 44) with 1 ticket.
nCr(44, 6)
Ans = 7.059052e6
5!
Ans = 120
5*4*3*2*1
Ans = 120
(9-2+1)!
Ans = 40320
Factorial(6)
Ans = 720
'Using random values:
'Rand gives a random value between 0 and 1
Rand
Ans = 0.745178223
'Rand(min,max) gives a random value between min and max
Rand(4,10)
Ans = 5.710388184
'Rand(max) gives a random value between 0 and max
Rand(8)
Ans = 2.880615234
'RandInt(min,max) gives a random number between min and max
RandInt(4,10)
Ans = 8
'RandInt(max) gives a random number between 0 and max
RandInt(22)
Ans = 17