Borrar filtros
Borrar filtros

Compute probability of a logical/boolean expression

2 visualizaciones (últimos 30 días)
Sara Nikdel
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.

Respuesta aceptada

Gaurav Garg
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.
  1 comentario
Sara Nikdel
Sara Nikdel el 13 de Ag. de 2020
Thank you so much for your response,
I was wondering if it is possible to call a funcrion instead of having an operation such as x+y.
Since the calculations vary based on the number of the input valuses, I wrote down a function for each OR and AND operations.
Best,
Sara

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Formula Manipulation and Simplification en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by