Compute probability of a logical/boolean expression

조회 수: 5 (최근 30일)
Sara Nikdel
Sara Nikdel 2020년 8월 6일
댓글: Sara Nikdel 2020년 8월 13일
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에서 Formula Manipulation and Simplification에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by