Compute probability of a logical/boolean expression

6 次查看(过去 30 天)
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.

采纳的回答

Gaurav Garg
Gaurav Garg 2020-8-10
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 个评论
Sara Nikdel
Sara Nikdel 2020-8-13
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by