
The risk parameter introduces randomness into the cost calculation, which means that when risk > 0, the cost will vary on each calculation. Because we recalculate the cost on every render, we sometimes flash different results for the same combination of parameters (e.g., on screen resizing), which might be confusing without full context.
Memoizing this calculation based on the parameters should fix this and would be a nice little UI improvement!