Work out a general approach to clipping.
tobiasraabe opened this issue · 2 comments
- Date you used respy: 11.08.
- respy version used, if any: 2.0.0-dev
- Python version, if any: any
- Operating System: any
Description
We clip values in different places at zero or at +-HUGE_FLOAT
which is +-1e20
. There are some general and specific issues with this approach.
General questions
-
Where should values be clipped?
Probably it is best to clip as early as possible so that we do not lose much information. This proved to be critical while calculating the likelihood, but could also extend to other places.
But, clipping very early for various components means a lot of code duplication. Maybe we need a convenience wrapper for clipping at logs and non-logs which centralizes the logic.
-
At what values should clipped?
-744 and 709 are approximately the borders of representable logged numbers. Maybe we want to clip earlier so that the next calculation does not yield another overflow? What is the reason for choosing
1e20
for non-logs?
Specific questions
- We clip logged numbers, e.g.
log_wage_systematic
, at+HUGE_FLOAT
which is less precise than clipping at 709 or something like that becausenp.exp(710) = inf
. - If we want to extract type and observable information from the state space as proposed in #237, we have postpone the current clipping in
_create_reward_components
to the aggregation function or do it multiple times.
We should also try to simply avoid clipping as often as possible since any form of clipping changes the results in unknown but potentially very relevant ways. It's a bit more difficult, but probably we could apply something similar to the adaptive rescaling approach when we calculate the emax.