From 646df90837fa35b6b38beb03f28e1a6b24d0013c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 30 Dec 2025 16:36:49 +0100 Subject: [PATCH] docs(ReforceXY): align mathematical notation with standard conventions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ReforceXY/reward_space_analysis/README.md | 14 +++++++------- .../reward_space_analysis/reward_space_analysis.py | 2 +- ReforceXY/user_data/freqaimodels/ReforceXY.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ReforceXY/reward_space_analysis/README.md b/ReforceXY/reward_space_analysis/README.md index f79e5cd..f080852 100644 --- a/ReforceXY/reward_space_analysis/README.md +++ b/ReforceXY/reward_space_analysis/README.md @@ -252,9 +252,9 @@ Let `pnl_target = profit_aim × risk_reward_ratio`, `pnl_ratio = pnl / pnl_targe - If `pnl_target ≤ 0`: `pnl_target_coefficient = 1.0` - If `pnl_ratio > 1.0`: - `pnl_target_coefficient = 1.0 + win_reward_factor × tanh(pnl_amplification_sensitivity × (pnl_ratio − 1.0))` + `pnl_target_coefficient = 1.0 + win_reward_factor * tanh(pnl_amplification_sensitivity * (pnl_ratio − 1.0))` - If `pnl_ratio < −(1.0 / risk_reward_ratio)`: - `pnl_target_coefficient = 1.0 + (win_reward_factor × risk_reward_ratio) × tanh(pnl_amplification_sensitivity × (|pnl_ratio| − 1.0))` + `pnl_target_coefficient = 1.0 + (win_reward_factor * risk_reward_ratio) * tanh(pnl_amplification_sensitivity * (|pnl_ratio| − 1.0))` - Else: `pnl_target_coefficient = 1.0` ##### Efficiency @@ -355,7 +355,7 @@ where: - `scale = base_factor · hold_potential_ratio` - `g = hold_potential_gain` - `T_pnl`, `T_dur` = configured transforms -- `m_dur = 1.0` if `r_pnl >= 0` (profit side) +- `m_dur = 1.0` if `r_pnl ≥ 0` (profit side) - `m_dur = risk_reward_ratio` if `r_pnl < 0` (loss side) The loss-side duration multiplier (`m_dur = risk_reward_ratio`) scales the @@ -387,15 +387,15 @@ losses compared to symmetric treatment. `r` = duration ratio and `grace` = `exit_plateau_grace`. ```text -r* = 0 if exit_plateau and r <= grace -r* = r - grace if exit_plateau and r > grace +r* = 0 if exit_plateau and r ≤ grace +r* = r - grace if exit_plateau and r > grace r* = r if not exit_plateau ``` | Mode | Formula | Monotonic | Notes | Use Case | | --------- | ------------------------------- | --------- | ------------------------------------------- | ------------------------------------ | | legacy | step: ×1.5 if r\* ≤ 1 else ×0.5 | No | Non-monotonic legacy mode (not recommended) | Backward compatibility only | -| sqrt | 1 / sqrt(1 + r\*) | Yes | Sub-linear decay | Gentle long-trade penalty | +| sqrt | 1 / √(1 + r\*) | Yes | Sub-linear decay | Gentle long-trade penalty | | linear | 1 / (1 + slope \* r\*) | Yes | slope = `exit_linear_slope` | Balanced duration penalty (default) | | power | (1 + r\*)^(-alpha) | Yes | alpha = -ln(tau)/ln(2); tau=1 ⇒ alpha=0 | Tunable decay rate via tau parameter | | half_life | 2^(- r\* / hl) | Yes | hl = `exit_half_life`; r\*=hl ⇒ factor ×0.5 | Time-based exponential discount | @@ -408,7 +408,7 @@ r* = r if not exit_plateau | `softsign` | x / (1 + \|x\|) | (-1, 1) | Linear near 0 | Less aggressive saturation | | `arctan` | (2/π) \* arctan(x) | (-1, 1) | Slower saturation | Wide dynamic range | | `sigmoid` | 2σ(x) - 1, σ(x) = 1/(1 + e^(-x)) | (-1, 1) | Standard sigmoid | Generic shaping | -| `asinh` | x / sqrt(1 + x^2) | (-1, 1) | Outlier robust | Extreme stability | +| `asinh` | x / √(1 + x²) | (-1, 1) | Outlier robust | Extreme stability | | `clip` | clip(x, -1, 1) | [-1, 1] | Hard clipping | Preserve linearity | ### Skipping Feature Analysis diff --git a/ReforceXY/reward_space_analysis/reward_space_analysis.py b/ReforceXY/reward_space_analysis/reward_space_analysis.py index 22c318c..5a20b0e 100644 --- a/ReforceXY/reward_space_analysis/reward_space_analysis.py +++ b/ReforceXY/reward_space_analysis/reward_space_analysis.py @@ -4012,7 +4012,7 @@ def write_complete_statistical_analysis( f.write(f"| Mean PBRS Delta | {mean_pbrs:.6f} | Average γ·Φ(s') - Φ(s) |\n") # noqa: RUF001 f.write(f"| Std PBRS Delta | {std_pbrs:.6f} | Variability of PBRS delta |\n") f.write( - f"| Mean Invariance Correction | {mean_inv_corr:.6f} | Average reward_shaping - pbrs_delta |\n" # noqa: RUF001 + f"| Mean Invariance Correction | {mean_inv_corr:.6f} | Average reward_shaping - pbrs_delta |\n" ) f.write( f"| Std Invariance Correction | {std_inv_corr:.6f} | Variability of correction |\n" diff --git a/ReforceXY/user_data/freqaimodels/ReforceXY.py b/ReforceXY/user_data/freqaimodels/ReforceXY.py index 66c3ef6..3818ecd 100644 --- a/ReforceXY/user_data/freqaimodels/ReforceXY.py +++ b/ReforceXY/user_data/freqaimodels/ReforceXY.py @@ -2392,7 +2392,7 @@ class MyRLEnv(Base5ActionRLEnv): **Hold Potential Formula:** m_dur = 1.0 if r_pnl >= 0 else loss_duration_multiplier(r_pnl, rr) - Φ(s) = scale · 0.5 · [T_pnl(g·r_pnl) + sgn(r_pnl)·m_dur·T_dur(g·r_dur)] + Φ(s) = scale · 0.5 · [T_pnl(g·r_pnl) + sign(r_pnl)·m_dur·T_dur(g·r_dur)] PBRS Theory & Compliance ------------------------ -- 2.53.0