You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I was exploring the no transaction band network and encountered an issue while working with BrownianStock. I set dt = 1/365 and time_horizon = 30/365, and after running the simulation, the generated tensor had the expected shape of (n_path, 31).
However, when I changed the time_horizon to 29/365, the tensor should have had a shape of (n_path, 30), but it still generated a shape of (n_path, 31).
This seems to be caused by the precision of floating-point numbers and the use of math.ceil() in line 140:
This issue arises due to the floating-point representation, where time_horizon/dt slightly exceeds 30, causing ceil() to return 31 instead of 30.
Proposed Fix
To address this, we can use the round() function to ensure more precise floating-point calculations. For instance:
frommathimportceildt=1/365time_horizon=29/365print(time_horizon/dt+1)
print(ceil(round(time_horizon/dt, 8) +1)) # Rounds to 8 decimal places
30.000000000000004
30 <-- Correct
This minor adjustment should fix the tensor shape mismatch. Thank you for considering this, and please let me know if any further adjustments are needed!
The text was updated successfully, but these errors were encountered:
Hi, I was exploring the no transaction band network and encountered an issue while working with BrownianStock. I set
dt = 1/365
andtime_horizon = 30/365
, and after running the simulation, the generated tensor had the expected shape of(n_path, 31)
.However, when I changed the time_horizon to
29/365
, the tensor should have had a shape of(n_path, 30)
, but it still generated a shape of(n_path, 31)
.This seems to be caused by the precision of floating-point numbers and the use of
math.ceil()
in line 140:pfhedge/pfhedge/instruments/primary/brownian.py
Line 140 in 1fc08c7
Example:
This issue arises due to the floating-point representation, where
time_horizon/dt
slightly exceeds 30, causingceil()
to return 31 instead of 30.Proposed Fix
To address this, we can use the
round()
function to ensure more precise floating-point calculations. For instance:This minor adjustment should fix the tensor shape mismatch. Thank you for considering this, and please let me know if any further adjustments are needed!
The text was updated successfully, but these errors were encountered: