-
-
Save gazon1/269b958ca41dc30424116f48d1e9ba5a to your computer and use it in GitHub Desktop.
Как сервисы наподобие youtube завладевавают вниманием?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Как сервисы наподобие youtube завладевавают вниманием? | |
# Пусть вероятность отвлечься на один фактор = 10%, тогда, если факторов уже 10 (их | |
# расположение не имеет значения - то есть можно их менять местами), то: | |
def C(n, k): | |
if 0 <= k <= n: | |
nn = 1 | |
kk = 1 | |
for t in range(1, min(k, n - k) + 1): | |
nn *= n | |
kk *= t | |
n -= 1 | |
return nn // kk | |
else: | |
return 0 | |
from itertools import accumulate | |
from operator import mul | |
length = 10 | |
ratio = 0.1 | |
progression_1 = list(accumulate([ratio]*length, mul)) | |
ratio = 0.9 | |
progression_9 = list(accumulate([ratio]*length, mul))[::-1] | |
pr_del = [C(10, k) for k in range(1, 11)] | |
r = [a*b for a,b in zip(progression_1, progression_9)] | |
r2 = [a*b for a,b in zip(r, pr_del)] | |
print(sum(r2)) # 0.586 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment