1. Classical probabilities
For example: Mahjong starts to touch the 14 cards without the probability, two identical cards will be, then there are:
All cases: Choose 14 cards from 136 cards for C136-14
No will: The different cards grouped, a total of 34 groups, then take 14 cards, the first time the extraction of c34-1 * 4, the second time for the c33-1 * 4
Total (C34-1 * 4) * (C33-1 * 4) * .... * (C21-1 * 4) = c34-14 * 4^14
Then the probability of no will is c34-14 * 4^14/c136-14
2. From 1!, 2!, 3!, 4!, to n! All the numbers in the first place is 1 probability, the first is the probability of 2, the first is the probability of 3, until the first is the probability of 9
The code is implemented as follows:
#!/usr/bin/env python#! _*_ coding:utf-8 _*_deffirst_number (n):" "First Digit" " whileN >= 10: N= N/10returnNdefsecond_number (n):" "Second Digit" " whileN >= 100: N= N/10returnN% 10defthird_number (n):" "Third Digit" " whileN >= 1000: N= N/10returnN% 100if __name__=="__main__": #initializes the frequency list, Requency[i] represents the number of occurrences of the first 1frequency = [0 forIinchRange (0, 10, 1)] I= 1#do factorial operations, from 1! , 2! , 3! , until 100! The Operation forNinchRange (1, 100, 1): I= n *i m=First_number (i) frequency[m]= Frequency[m] + 1PrintFrequency
Results:
/users/liudaoqiang/pycharmprojects/numpy/venv/bin/python/users/liudaoqiang/project/python_project/bat_day17/ 7, 7, 7, 3, ten, 4]process finished with exit code 0
3. Ben Ford's Law:
In life, the probability of the first digit being 1 is nearly 1/3, which is 3 times times the 1/9.
Practical application:
(1) factorial, Prime number series, Fibonacci series first
(2) Residential address number,
(3) Economic data anti-fraud, vote anti-fraud
Python data structures and algorithms 17th Day "Probabilistic algorithm"