Skip to content

Fix survival chance per timestep calculation#287

Merged
Capkirk123 merged 1 commit intodevfrom
FixHazardRate
Nov 15, 2025
Merged

Fix survival chance per timestep calculation#287
Capkirk123 merged 1 commit intodevfrom
FixHazardRate

Conversation

@Nazfib
Copy link

@Nazfib Nazfib commented Nov 10, 2025

TF consistently interprets the 'momentary failure rate' curve as 'instantaneous hazard rate' — the proportional failure rate of systems still working at the current time — for display purposes (e.g. the 'Reliability' and 'MTBF' displays are calculated as if it is the hazard rate). However, the conversion to a failure chance per update cycle wasn't done correctly, and the actual failure rate over time didn't match the instantaneous MTBF when the failure rate is not constant.

Now, the cycle reliability curve directly specifies the hazard rate h(t) (which is the same as the 'failure rate' λ(t)), and the chance to fail over a timestep Δt is h(t)*Δt.

Below is a plot of the cumulative failure distribution with 10 000 random samples, for both implementations. 'TestFlight' is the current implementation in TF; 'h·Δt' is the fixed implementation in this PR.
ExampleCDF

Many thanks to KSP-RO Discord user 'igui', who first found this problem and helped figure out the details of the implementation and this fix.

Make sure you have read and understood the contributing guidelines!

Pull Requests that don't follow the guidelines will be rejected. If you need help or are confused just ask, and we will be glad to help.

  • [x ] PR being applied to the correct Feature Branch or dev
  • [ x] PR is not being sent to master

TF consistently interprets the 'momentary failure rate' curve as
'instantaneous hazard rate' - the proportional failure rate of systems
still working at the current time - for display purposes (e.g. the
'Reliability' and 'MTBF' displays are calculated as if it is the hazard
rate). However, the conversion to a failure chance per update cycle
wasn't done correctly, and the actual failure rate over time didn't
match the instantaneous MTBF when the failure rate is not constant.

Now, the cycle reliability curve directly specifies the hazard rate h(t)
(which is the same as the 'failure rate' λ(t)), and the chance to fail
over a timestep Δt is h(t)*Δt.
@jwvanderbeck
Copy link
Collaborator

I have no issues with this change. I always said from the start that I didn't fully understand the math involved, but it sounds like you do :)

This will have long tail repercussions in overall game play though so that's up to the current RP maintainers to decide.

@igui
Copy link

igui commented Nov 10, 2025

For more context, last week in the RO/RP Discord we discussed this problem, analyzed the possible solutions.

@Capkirk123
Copy link
Member

I have no concerns, making the actual failure rate match displayed failure rate is obviously desirable and the change during normal runtime seems fairly minor.

If the longer tail becomes a balance issue we can just tweak the curves directly.

@jwvanderbeck
Copy link
Collaborator

jwvanderbeck commented Nov 10, 2025 via email

@Capkirk123
Copy link
Member

I'll merge now, and see how it goes. If it becomes a problem we can adjust the curves later.

@Capkirk123 Capkirk123 merged commit fac2ae2 into dev Nov 15, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants