Add files via upload

This commit is contained in:
Silviu Marian Udrescu 2020-03-08 13:53:10 -04:00 committed by GitHub
parent 7ee026cb1c
commit 41f66199b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 70577 additions and 0 deletions

View file

@ -0,0 +1,21 @@
# Calculates the complexity of a number to be used for the Pareto frontier after snapping
import numpy as np
from S_snap import bestApproximation
def get_number_DL_snapped(n):
epsilon = 1e-10
n = float(n)
if np.isnan(n):
return 1000000
elif np.abs(n - int(n)) < epsilon:
return np.log2(1 + abs(int(n)))
elif np.abs(n - bestApproximation(n,10000)[0]) < epsilon:
_, numerator, denominator, _ = bestApproximation(n, 10000)
return np.log2((1 + abs(numerator)) * abs(denominator))
else:
PrecisionFloorLoss = 1e-14
return np.log2(1 + (float(n) / PrecisionFloorLoss) ** 2) / 2