Compute probability of a logical/boolean expression
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sara Nikdel
el 6 de Ag. de 2020
Comentada: Sara Nikdel
el 13 de Ag. de 2020
Hi,
I have boolean expressions as inputs, then I want to simplify the expression as it is shown below.
syms a b c;
mcs(a,b,c) = simplify((a|b)&c);
the output will be a symfun:
>> mcs(a, b, c) =
c & (a | b)
The struggle for me is how to assign probailities (scalars) to a , b , c; and apply the inclusion/exclusion principle to above expression.
Manually it will looks like somthing like this:
p(c) = 0.5;
p(a) = 0.5;
p(b) = 0.5;
p(a OR b) = p(a)+ p(b) - p(a)*p(b);
p = p(c)* p(a OR b);
But evantually my expressions are much more complicated than this example, so I need to figure out a smart way to this.
0 comentarios
Respuesta aceptada
Gaurav Garg
el 10 de Ag. de 2020
Hey Sara,
You can make 2 separate symfuns, each for OR and AND operations, and evaluate the expressions. You can then directly call the function with the values and get the result.
Let's say you can define OR and AND functions as:
syms OR(x,y)
OR(x,y) = x + y
syms AND(x,y)
AND(x,y) = x + y
And you expression is (assuming you already have the values for x,y,z defined):
OR(z , OR(x,y) )
Calling the function above would give you the result.
Más respuestas (0)
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!