Initialize the markov process management of the system.
Parameters : |
|
---|
Examples
Let S be a system of two components A and B.
>>> from fiabilipy import Component
>>> A, B = Component('A', 1e-2), Component('B', 1e-6)
>>> comp = (A, B)
>>> init = [0.8, 0.1, 0.1, 0]
>>> process = Markovprocess(comp, init)
In a general way init[i] is the probability of having:
>>> for c, state in enumerate(binary_repr(i, len(components))):
>>> if state:
>>> print('%s working' % components[c])
>>> else:
>>> print('%s not working' % components[c])
As initstates may be very sparse, it can be given through a dictionnary as follow:
>>> init = {}
>>> init[0] = 0.8
>>> init[1] = init[2] = 0.1
Print the content of the dot file needed to draw the markov process
Parameters : | output (file-like object, optional) – If output is given, then the content is written into this file. output must have a write() method. |
---|
Notes
Please, see the Graphviz website to have more information about how to transform the ouput code into a nice picture.
Compute the probability of being in some states.
Parameters : |
|
---|
Examples
>>> A, B, C, D = [Component(i, 1e-3) for i in xrange(4)]
>>> comp = (A, B, C, D)
>>> process = Markovprocess(comp, {0:1})
>>> availablefunc = lambda x: (x[0] or x[1]) and (x[2] or x[3])
>>> process.value(100, statefunc=availablefunc)
0.98197017562069511
So, at \(t = 100\), the probability for the system to be available is approximaltly 0.982.
If you want to know, the probability, at \(t = 1000\) that all the components work but the first one, you proceed like that
>>> allbutfirstfunc = lambda x: not x[0] and x[1] and x[2] and x[3]
>>> allbutfirststates = process.computestates(allbutfirstfunc)
>>> process.value(1000, states=allbutfirststates)
0.031471429479129759