# Assumption Ignored Symbolic PDF

3 views (last 30 days)
Lea on 26 Feb 2023
Commented: Paul on 27 Feb 2023
I want to define as the probability density function of the random variable z. is the cumulative density function.
As , if is the probability density function of z.
However, Matlab ignores this assumption (see code below). Why is that the case and how can I fix it?
Thanks for any help :)
% Set symbols
syms x y beta db dc d
syms z f(z) F(z) % z, its PDF and CDF
syms rd(z) rp(z) % other functions that depend on z
% Assumptions on parameters
assume(x>0)
assume(y>0)
assume(beta*x<y)
assume(beta<1 & beta>0)
assume(F(z)<=1 & F(z)>=0) % CDF of z
% PDF of z
f(z) == diff(F(z),z)
ans =
assume(f(z)>=0)
assume(int(f(z), z, 0,1)==1)
Warning: Ignored assumptions on constants.
%*************************************************************************************
Vb = log(x-db) + beta * int((z * log(rp(z)*db)*f(z)), z, 0,1) ...
+ beta * int(((1-z) * log(rd(z)*db)*f(z)), z, 0,1)
Vb =
%*************************************************************************************
% differentiate Vb w.r.t. db and set equal to 0
diff_Vb_db = diff(Vb, db) == 0
diff_Vb_db =
isolate(diff_Vb_db, db)
ans =
##### 3 CommentsShow 1 older commentHide 1 older comment
Lea on 26 Feb 2023
Edited: Lea on 26 Feb 2023
Hi @Paul,
Yes, you are of course right about F(z) = 0 for < 0 and F(z) = 1 for z > 1, sorry about that.
To give you some context: Vb is a utility function I am trying to maximize by choose the optimal value of db (= savings).
How can I ask Matlab to assume
assume(int(f(z), z, 0,1)==1) ?
Because using that information, the derivative of Vb w.r.t. db set equal to 0 simplifies substantially:
diff_Vb_db = diff(Vb, db) == 0
I would like to set the assumption correctly, so that Matlab arrives at this result by itself...
Or is there another (more efficient way) to tell Matlab that f(z) is the PDF of z and F(z) its CDF with F(z) = 0 for < 0 and F(z) = 1 for z > 1 that would allow me to arrive at said result?
Walter Roberson on 26 Feb 2023
assume(int(f(z), z, 0,1)==1)
You have implicitly told MATLAB that f is a function of a single variable. The definite integral of a function of a single variable is a constant. Constant == constant is either symtrue or symfalse, and assuming() symtrue or symfalse is ignored.
If you had declared f as being a function of more than one variable, then the int() would not be considered a constant.

Paul on 26 Feb 2023
I'm not aware of a way to put an assumption like that on an integral.
In this problem, it seems like the actual form of f(z) doesn't matter, so I suppose you could just assign f(z) to be any function that satisfies the integral constraint.
Or, these manipulations worked, but I'm not sure they will generalize. I had to play around a bit to get the expressions into the correct form for the subs command to work
syms f(z)
syms db beta x real
assumeAlso(db ~= 0);
assumeAlso(db ~= x);
eqn = beta*int(-f(z)*(z-1)/db,z,0,1) + beta*int(f(z)*z/db,z,0,1) + 1/(db - x) == 0
eqn =
eqn = simplify(eqn)
eqn =
eqn = expand(eqn)
eqn =
eqn = subs(eqn,int(f(z),z,0,1),1)
eqn =
eqn = beta/db - simplify(solve(eqn,beta)/db) == 0
eqn =
Lea on 27 Feb 2023
Ah, I see! Thanks for clarifying!
Also thanks again to @Torsten and @Paul; I will now accept this comment as the answer to my question.
Paul on 27 Feb 2023
I agree that assume doesn't allow for assuming the integral is a particular constant, which is why the original solution posted above used subs for the integral (after some manipulation to get the expression into a form where subs would work). However, I'm wondering if that's the expected behavior based on the linked doc page, which says:
"The toolbox does not support assumptions on symbolic functions. Make assumptions on symbolic variables and expressions instead." (emphasis added)
Let's test this with a simple case
syms x y
symType(x*y)
ans = "expression"
We see that x*y is an expression, so it should be assumable
assume(x*y == 1);
assumptions
ans =
It is. And the assumption yields the expected result
simplify(x*y)
ans =
1
Now try with int
syms f(z)
symType(int(f(z),z,0,1))
ans = "expression"
Also an expression. But this expression is not assumable
assume(int(f(z),z,0,1) == 1)
Warning: Ignored assumptions on constants.
assumptions
ans =
What's the difference between x*y and the int(...) expressions as far as assume() is concerned?

### Categories

Find more on Assumptions in Help Center and File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!