Robin_PHD/component_failure_modes_definition/unitary_state.bc
2010-08-28 20:18:47 +01:00

43 lines
839 B
Plaintext

# NOT FINISHED YET !!!!
# define a factorial function
# gives 1 for negative values as well
define f(x) {
if (x>1) {
return (x * f (x-1))
}
return (1)
}
# determine how many combinations would be dis-allowed
# from a cardinality constrained powerset
# given unitary state failure mode conditions
define uc(k,c,x) {
aa = 0;
for(i=2; i<=k; i++) aa += c * f(c)/(f(i)*f(c-i));
return aa;
}
# cardinality constrained powerset
# how many combinations of cardinality k
# can we have from c number of components
# with x number of failure modes
define ccps(k,c,x) {
return f(c*x)/(f(k)*f(c*x-k))
}
define us(k,c,x) {
a=0;
for(i=1;i<=k;i++) a += ccps(i,c,x);
# a now holds all combinations
# we must now subtract those combinations
# dis-allowed under unitary state conditions.
a -= uc(k,c,x);
return a;
}
us(2,3,3);