I’m a reliability engineer (definitely not an experienced Python programmer) seeking to run a discrete-use system simulation in Python, and I’m having some trouble simulating failure mode first occurrence test failures. A discrete-use system is one that typically has its usage measured in terms of demands, for example, a missile system. The system is in standby most of the time, and when required, we ‘demand’ the system. The system then has two possible demand outcomes – success (our missile fires) or failure (our missile doesn’t).
Let’s say our system has failure mode rates of occurrence represented by f_rate.
I now want to simulate the ‘First Occurrence on Test’ of each failure mode by randomly drawing from a geometric distribution related to that particular failure mode rate which is represented by FOT.
This is what a sample looks like:
import numpy as np
from scipy.stats import geom
# Example failure mode rates, f_rate
f_rate = [0.01243683, 0.12391001, 0.01397139, 0.00799507, 0.01395825,
0.00712858, 0.06471261, 0.07430849, 0.10902522, 0.17184146]
# Simulate FOT for each mode from a geometric distribution
FOT = np.empty(len(f_rate))
for i in range(len(f_rate)):
FOT[i] = geom.rvs(f_rate[i])
# Print first occurrence on test of failure mode
print(FOT)
And an example of a result:
[146. 6. 99. 132. 124. 127. 14. 6. 2. 10.]
Discrete-use systems are typically serial: that is, failure of any subsystem in its operating sequence results in system failure. As such, no more than one failure mode can physically present on a single demand. From my example, we can see that two failures occurred during demand 6, but in reality, this is not possible (the first failure mode would cause system failure, so the second demand 6 failure mode would never eventuate).
How can I keep the first sixth demand failure at FOT[1], but also resample FOT[7] from the failure rate in f_rate[7]?
I need to ensure no repetition in FOT to ensure the model represents reality, and I’m just not sure how to (1) identify the FOT index repeats and then (2) resample from the correct f_rate index, but only for the duplicate values. I’m assuming I need to identify the index of all duplicates less the first, resample from the appropriate corresponding index, and then check again for duplicates?
The result should be representative of:
[146. 6. 99. 132. 124. 127. 14. 31. 2. 10.]
Any help/suggestion ?
If the probability of collision is low enough, you could just test if a demand failure already occured and in that case ask a new one:
# Simulate FOT for each mode from a geometric distribution
FOT = np.empty(len(f_rate))
for i in range(len(f_rate)):
while True:
val = geom.rvs(f_rate[i])
if val not in FOT[:i]:
FOT[i] = val
break