I need to generate a certain number of random failures throughout the lifetime of a certain component. I possess the failure rate of the component, i.e. if I know that it fails for instance 6 times in 720 hours of work, then its failure rate is 6/720 = 0.0083 failures/hour. Now, if I consider two possible states of functioning (0 = component works fine, 1 = components has failed), I would like to create in Matlab a script that provides me an array which for each one of the 720 hours of the total lifetime it gives me a 0 or a 1, whether the component is working or not, based on its known failure rate. Many thanks.
Asked
Active
Viewed 1,124 times
0
-
1The solution depends pretty strongly on assumptions about how the world works. E.g. if a component fails, does it stay failed, can it go back to the functional state, or is it replaced with an identical component? What is the distribution of failure events? See also: [survival analysis](http://en.wikipedia.org/wiki/Survival_analysis) – Robert Dodier May 19 '15 at 19:12
-
Since you speak of "for each hour", I guess you want to consider discrete time? – A. Donda May 19 '15 at 20:37
2 Answers
2
Another example
numFailures = 6;
timeLength = 720; % hours
pFailure = numFailures / timeLength;
% call this to randomly determine if there was a failure. If called enough times the probability of 1 will be equal to pFailure
isFailed = rand(1) < pFailure;
We can verify by calling in a loop:
for k=1:1e5
isFailed(k) = rand(1) < pFailure;
end
sum(isFailed)/k
ans =
0.008370000000000

siliconwafer
- 732
- 4
- 9
0
One of many solutions:
numFailures = 6;
timeLength = 720; % hours
% create array with one element per hour
p = false(1, timeLength);
p(1:numFailures) = true;
% randomly sort p
p = p(randperm(timeLength));
% generate a random index for sampling
index = randi(timeLength, 1);
% Sample the array
% this will be true if there was a failure
p(index)

siliconwafer
- 732
- 4
- 9