HP PPL and Statistical distributions
|
05-22-2021, 06:46 PM
Post: #19
|
|||
|
|||
RE: HP PPL and Statistical distributions
Some issues with PYTHON program (assumed it is true Python):
1. Turning repeat until to while loop must ensure it run at least once. Loop counts must also match. It might be safer translate repeat-until as: while 1: ... if until_condition: break 2. True Python does not turn 1./0. to +inf, but raise ZeroDivisionError instead. Why Python's ZeroDivisionError for floating-point type is a bad and unnecessary feature In fact, Python seldom return float('inf'), for floating math operations. (1e300*1e300 return +inf, but 1e300 ** 2 raise OverflowError ... weird) >>> from math import * >>> log(0) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: math domain error >>> exp(1000) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: math range error We have to catch exceptions instead. see emece67 double_exponential.py This is why quad.lua translated to PPL. It behave closer to Lua: CAS> 1./0. → +Inf CAS> log(0.) → -Inf CAS> exp(1000.) → +Inf |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)