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
SELECT IV.client__description as "client_description", | |
IV.invoice_date, | |
IV.amount | |
FROM Invoice_View IV |
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
# Calculate Confidence Intervals for probability matrix | |
def calc_confidence_interval(alpha): | |
alpha_stat = stats.norm.ppf(1 - (1 - alpha) / 2) | |
for d_i in range(expected_prob_matrix.shape[0]): | |
for n_i in range(expected_prob_matrix.shape[1]): | |
prop_exp = expected_prob_matrix[d_i, n_i] | |
half_length = alpha_stat * (prop_exp * (1 - prop_exp) / data_cols_length[n_i]) ** .5 + ( | |
1 / (2 * data_cols_length[n_i])) | |
u_bound = prop_exp + half_length |
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
# Probability of digit (d) occurring in nth position | |
def calc_expected_probability(d: int, n: int) -> float: | |
# generalization of Benford's Law ~ Summation( log[ 1 + (1/(10k+d)] ) where d = digit, k = (10^(n-2), 10^(n-1)) | |
# source: https://en.wikipedia.org/wiki/Benford%27s_law | |
prob = 0 | |
if (d == 0) and (n == 1): | |
prob = 0 | |
elif n == 1: | |
prob = math.log10(1 + (1 / d)) | |
else: |