This file contains hidden or 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
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) |
This file contains hidden or 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
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 |
This file contains hidden or 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
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) |
This file contains hidden or 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
from mpmath import betainc | |
p=betainc(a_T, b_T, 0.003,1, regularized=True) #result: 0.48112566853812544 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
OlderNewer