11 Handshaking combinations
11 Handshaking combinations#
%%html
<iframe width="700" height="400" src="https://www.youtube.com/embed/boH4l1SgJbM/" frameborder="0" allowfullscreen></iframe>
import itertools
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats, special
persons = ['A', 'B', 'C', 'D']
shakes = [1, 2]
p = list(itertools.permutations(persons, len(shakes)))
c = list(itertools.combinations(persons, len(shakes)))
p
[('A', 'B'),
('A', 'C'),
('A', 'D'),
('B', 'A'),
('B', 'C'),
('B', 'D'),
('C', 'A'),
('C', 'B'),
('C', 'D'),
('D', 'A'),
('D', 'B'),
('D', 'C')]
c
[('A', 'B'), ('A', 'C'), ('A', 'D'), ('B', 'C'), ('B', 'D'), ('C', 'D')]
len(p)
12
len(c)
6
special.perm(len(persons), len(shakes))
12.0
special.comb(len(persons), len(shakes))
6.0