MaPal93

175 Reputation

5 Badges

2 years, 135 days

MaplePrimes Activity


These are questions asked by MaPal93

Please check: Finding_Chi_Version1.mw

My end goal is to find the following three expressions:

chi_1 := collect(X_A,[nnu[1],nnu[2]]);

chi_2 := collect(X_B,[nnu[1],nnu[2]]);

chi_3 := collect(X_C,[nnu[1],nnu[2]]);

I expect these three expressions to be linear combinations of random variables nu[1] (nnu[1]) and nu[2] (nnu[2]).

While calling solve(), I encounter this error:

Error, (in assuming) when calling 'SolveTools:-Engine:-Dispatch'. Received: 'badly formed input to solve: not fully algebraic'

What is exactly the issue here? If it can help you answer my doubt, that argmin expression I defined is composed by conditional means and variances which I computed as in here: conditional_distributions_Version1.mw

The two formulas I am trying to implement in Maple are conditional distribution of a multivariate normal distributionAm I already doing any mistake in conditional_distributions_Version1.mw? An alternative interpretation of mine for these two formulas is: conditional_distributions_Version2.mw. Please check the light-blue-highlighted differences in the conditional variance calculation. This alternative interpretation leads to Finding_Chi_Version2.mw, which I also can't solve() (solver stuck in "evaluating") but at least I don't get the error mentioned above...

I am a bit lost to be honest: Is Finding_Chi_Version1 or Finding_Chi_Version2 the correct interpretation? 

Thanks!

How to use collect() or coeffs() on random variables instead of standard variables?

I need to re-organize a linear combination of RVs nu[1], nu[2], u[1], u[2], u[3] by collecting the coefficients on each of these 5 RVs. Note that the Xs are correlated with each other and the Ys are correlated with each other (but Xs and Ys are uncorrelated).

For example, nu is a 2D gaussian vector where nu[1] and nu[2] are defined in terms of _R1, _R2, means, standard deviations and correlation coefficient. They are quite "nested" and the 3D gaussian vector u is even worse, so when these enter a linear combination it becomes hard to identify them back as simply nu[1], nu[2], u[1], u[2], u[3].

Is there a way to "isolate" them in a linear combination by using collect()-like or coeffs()-like functions (i) directly on the RVs or (ii) indireclty on the explicit expressions of _Rs, means, standard devs, correlation coeffs? 

(I already checked the answers to these two somewhat similar questions but did not help for my case:

https://mapleprimes.com/questions/235215-Reduce-Length-Of-Sum-Of-Products

https://mapleprimes.com/questions/234292-Re-How-To-Collect-Using-A-Term-By-Multiplication

)

See my script below: 

For example, I would want collect() on nu[1] (or equivalently on _R1*sigma__v[1]+nu__0[1]) to give me X__1+X__3 (as you easily see from my definition of Omega).

# 2.2.1 Define the Omega random variable as Omega__1+Omega__2+Omega__3:

`Ω__1` := X__1*(nu[1]-`μ__1`-`λ__1`*(u[1]+X__1)); `Ω__2` := X__2*(nu[2]-`μ__2`-`λ__2`*(u[2]+X__2)); `Ω__3` := X__3*(nu[1]+nu[2]-`μ__3`-`λ__3`*(u[3]+X__3)); Omega := `Ω__1`+`Ω__2`+`Ω__3`

X__1*(sigma__v[1]*_R1+nu__0[1]-mu__1-lambda__1*(_R3*sigma__u[1]+X__1))+X__2*(sigma__v[2]*rho__v[1, 2]*_R1+(-rho__v[1, 2]^2+1)^(1/2)*sigma__v[2]*_R2+nu__0[2]-mu__2-lambda__2*(rho__u[1, 2]*sigma__u[2]*_R3+(-rho__u[1, 2]^2+1)^(1/2)*sigma__u[2]*_R4+X__2))+X__3*(sigma__v[1]*_R1+nu__0[1]+sigma__v[2]*rho__v[1, 2]*_R1+(-rho__v[1, 2]^2+1)^(1/2)*sigma__v[2]*_R2+nu__0[2]-mu__3-lambda__3*(rho__u[1, 3]*sigma__u[3]*_R3-sigma__u[3]*(rho__u[1, 2]*rho__u[1, 3]-rho__u[2, 3])*_R4/(-rho__u[1, 2]^2+1)^(1/2)+((-2*rho__u[1, 2]*rho__u[1, 3]*rho__u[2, 3]+rho__u[1, 2]^2+rho__u[1, 3]^2+rho__u[2, 3]^2-1)/(rho__u[1, 2]^2-1))^(1/2)*sigma__u[3]*_R5+X__3))

(1)

# 2.2.2 Simplify and re-arrange the Omega RV to obtain the easy-to-read version (a,b,c,d,e,f are the coefficients):
#Omega__* = a + b*nu[1] + c*nu[2] + d*u[1] + e*u[2] + f*u[3];
# How to do it? Collect() does not work...simplify() doesn't make it any easier...

`Ω__*` := collect(Omega, [_R1*`σ__v`[1]+`ν__0`[1], `σ__v`[2]*`ρ__v`[1, 2]*_R1+sqrt(-`ρ__v`[1, 2]^2+1)*`σ__v`[2]*_R2+`ν__0`[2], `σ__u`[1]*_R3, `σ__u`[2]*`ρ__u`[1, 2]*_R3+sqrt(-`ρ__u`[1, 2]^2+1)*`σ__u`[2]*_R4, `σ__u`[3]*`ρ__u`[1, 3]*_R3-`σ__u`[3]*(`ρ__u`[1, 2]*`ρ__u`[1, 3]-`ρ__u`[2, 3])*_R4/sqrt(-`ρ__u`[1, 2]^2+1)+sqrt((-2*`ρ__u`[1, 2]*`ρ__u`[1, 3]*`ρ__u`[2, 3]+`ρ__u`[1, 2]^2+`ρ__u`[1, 3]^2+`ρ__u`[2, 3]^2-1)/(`ρ__u`[1, 2]^2-1))*`σ__u`[3]*_R5])

Error, (in collect) cannot collect _R1*sigma__v[1]+nu__0[1]

 

`Ω__col` := collect(Omega, [nu[1], nu[2], u[1], u[2], u[3]])

Error, (in collect) cannot collect _R1*sigma__v[1]+nu__0[1]

 

 

Download collect.mw

Given a constant gamma, gaussian random variables S[1] and S[2], and a linear combination of gaussian random variables Omega, I need to compute Exp[ Omega | S[1], S[2] ] - (gamma/2)*Var[ Omega | S[1], S[2] ]. I am not experienced in Maple. In the attached script I include many step-by-step details on what I need to do, as well as some notes where I get stuck:

150423_OptimizationProblem.mw

It would be convenient if you could directly fix this and share the working version. Thanks!

The conditional means and variance terms are calculated according to the 2D version of the script 3_gaussian_mmcdara.mw provided by @mmcdara.

Linear combinations of random variables: why Maple does not "inherit" the distributional assumptions when adding up two random variables?

In the script I attach below, I first define a vector of two uncorrelated gaussian RVs [epsilon[1],epsilon[2]] and then a vector of two correlated gaussian RVs [nu[1],nu[2]]. Both epsilon[1] and epsilon[2] are also uncorrelated with nu[1] and nu[2].

Now I want to create a vector of two correlated gaussian RVs, S, where S[1]=nu[1]+epsilon[1] and S[2]=nu[2]+epsilon[2]. The means and the variances of [S[1],S[2]] are correct, but the covariance (off-diagonal element of the covariance matrix) is weird. How to do this in Maple?

Please check this script:

RVs_sum.mw

 

Hello everyone,

Here is a stylized version of my problem. Given three normally distributed random variables {A, B, C}, I want to find the X_1, X_2, X_3 that maximize the following expression (gamma being a constant and A being a linear combination of other normally distributed random variables):

Max{ Exp[A|B,C] - (gamma/2)*Var[A|B,C] }

All the details are here: 070423_Optimization.mw

In particular, I am seeking your help to:

  1. Correlate three random variables (an example of the procedure for correlating two random variables is already provided in the script).
  2. Verify my understanding of the linear projection theorem (https://stats.stackexchange.com/questions/30588/deriving-the-conditional-distributions-of-a-multivariate-normal-distribution) in two dimensions, that is, to compute conditional means and variances of the form E[X|Y,Z] and V[X|Y,Z].
  3. Implement and adapt the linear projection theorem to my problem in Maple.
  4. Combine all together to obtain Expr = E[A|B,C] + V[A|B,C] and find the optimal {X_1, X_2, X_3} by solving the linear system of three equations in the three variables {X_1, X_2, X_3}, where the three equations are obtained by setting to 0 the partial derivatives of Expr with respect to {X_1, X_2, X_3}.

 

In relation to point 2., did I correctly interpret the matrix form of the three-dimensions version of the linear projection theorem?

 

In relation to point 3., I attach a stylized script for the three-dimensions version (note that I need the two-dimensions version for my problem): LinearProjectionTheorem_3dimensions.mw. Assuming a correct interpretation of the theorem:

  • Did I correctly implement E[X_2|Y_1,Y_2,Y_3] and E[X_3|Y_1,Y_2,Y_3] as in the picture above?
  • How to adapt it accordingly to include E[X_1|Y_1,Y_2,Y_3] and V[X_1|Y_1,Y_2,Y_3], V[X_2|Y_1,Y_2,Y_3], and V[X_3|Y_1,Y_2,Y_3]? 
  • How to apply it to the random variables in my script to eventually find the optimal {X_1,X_2,X_3}?

 

You can play around with my script 070423_Optimization.mw and send me the updated version. The problem I am trying to solve is quite convoluted, so let me know if you need any further clarification. Thanks a lot!

First 6 7 8 9 Page 8 of 9