Created
January 16, 2017 14:49
-
-
Save jcbozonier/3298785cb5532c8ff3db99cf307493d8 to your computer and use it in GitHub Desktop.
Multiplication in log-space until 0 (negative infinity in log-space)
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 as np | |
aggregate_product = np.log(1) | |
iterations = 0 | |
while aggregate_product != float('-inf'): | |
aggregate_product += np.log(0.5) | |
iterations += 1 | |
# break program execution and then print out | |
print(iterations) | |
print(aggregate_product) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment