From ea48d7c6bf0a7ddb5375ccc3cf5af1192b498aa5 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 19 Nov 2017 23:29:05 -0500 Subject: [PATCH] WIP confidence intervals for suggested tags --- src/main/utils/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/utils/utils.py b/src/main/utils/utils.py index 44d03a7..4e21058 100644 --- a/src/main/utils/utils.py +++ b/src/main/utils/utils.py @@ -4,6 +4,8 @@ import os import pickle as pkl import subprocess from contextlib import suppress +from fractions import gcd +import math import aiohttp import discord as d @@ -157,3 +159,8 @@ def get_kwargs(ctx, args, *, limit=False): raise exc.BoundsError(arg) return {'destination': destination, 'remaining': remaining, 'remove': rm, 'limit': lim} +def ci(pos, n): + z = 1.96 + phat = float(pos) / n + + return (phat + z*z/(2*n) - z * math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)