bootstrap
This commit is contained in:
parent
3121276389
commit
7aa7ce80b9
85 changed files with 434224 additions and 0 deletions
23
prior-art/Code/S_get_number_DL_snapped.py
Normal file
23
prior-art/Code/S_get_number_DL_snapped.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# 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))
|
||||
elif np.abs(n - np.pi) < epsilon:
|
||||
return np.log2(1+3)
|
||||
else:
|
||||
PrecisionFloorLoss = 1e-14
|
||||
return np.log2(1 + (float(n) / PrecisionFloorLoss) ** 2) / 2
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue