Skip to content

Instantly share code, notes, and snippets.

View vlavorini's full-sized avatar

Vincenzo Lavorini vlavorini

View GitHub Profile
from math import lgamma
from numba import jit
@jit
def h(a, b, c, d):
num = lgamma(a + c) + lgamma(b + d) + lgamma(a + b) + lgamma(c + d)
den = lgamma(a) + lgamma(b) + lgamma(c) + lgamma(d) + lgamma(a + b + c + d)
return np.exp(num - den)
from scipy.stats import beta
import numpy as np
from calc_prob import calc_prob_between
#This is the known data: imporessions and conversions for the Control and Test set
imps_ctrl,convs_ctrl=16500, 30
imps_test, convs_test=17000, 50
#here we create the Beta functions for the two sets
a_C, b_C = convs_ctrl+1, imps_ctrl-convs_ctrl+1
from math import lgamma
from numba import jit
#defining the functions used
@jit
def h(a, b, c, d):
num = lgamma(a + c) + lgamma(b + d) + lgamma(a + b) + lgamma(c + d)
den = lgamma(a) + lgamma(b) + lgamma(c) + lgamma(d) + lgamma(a + b + c + d)
return np.exp(num - den)
from mpmath import betainc
p=betainc(a_T, b_T, 0.003,1, regularized=True) #result: 0.48112566853812544
import seaborn as sns
import pandas as pd
import numpy as np
imps_ctrl,convs_ctrl=16500, 30
imps_test, convs_test=17000, 50
#here we create the Beta functions for the two sets
a_C, b_C = convs_ctrl+1, imps_ctrl-convs_ctrl+1
a_T, b_T = convs_test+1, imps_test-convs_test+1
import numpy
from theano import shared
import pymc3 as pm
x = np.arange(len(df))
# we set a shared tensor useful for inference
x_shared = shared(x)
y = df['totale_casi'].values