Mathematica Asked on September 3, 2021
I’m trying to find the matrices of coefficients of a quadratic form:
Clear["Global`*"]
x[1] = CDF[NormalDistribution[[Mu], [Sigma]], c];
x[2] = Expectation[x^2 [Conditioned] x > c,
x [Distributed] NormalDistribution[[Mu], [Sigma]]];
x[3] = 1 - CDF[NormalDistribution[[Mu], [Sigma]], c];
m = Table[a[i, j], {i, 1, 3}, {j, 1, 3}]
n = Table[b[i], {i, 1, 3}]
vars = Table[x[i], {i, 1, 3}]
fun[[Mu]_, [Sigma]_, c_, o_] =vars.m.vars + n.vars + o
Suppose that all I observe is the expression for $text{fun}$. I want to express it in matrix form in order to easily perform sums with other similar quadratic expressions. That is, I want to find ${tilde{m}, tilde{n},tilde{o}}$ such that $text{fun(μ,σ,c,o)} ≡ text{vars}^{prime} tilde{m} text{vars} +text{vars}^{prime} tilde{n} + tilde{o}$. My attempt using CoefficientArrays
has not been successful:
{oo, nn,mm} =
Normal@CoefficientArrays[fun[[Mu], [Sigma], c, o], vars];
Any ideas on how to do that?
For some reason, those functions are not recognized as variables by CoefficientArrays
. So, the following trick ended up by useful:
fun2[[Mu]_, [Sigma]_, c_,o_] = fun[[Mu], [Sigma], c,o]//. x[3] -> xx[3] //. x[2] -> xx[2] //. x[1] -> xx[1];
vars2=Table[xx[i], {i, 1, 3}];
{oo, nn,mm} =
Normal@CoefficientArrays[fun2[[Mu], [Sigma], c,o],vars2];
Verifying it:
vars.mm.vars + nn.vars + oo == fun[[Mu], [Sigma], c,o] // Simplify
(* True *)
Correct answer by capadocia on September 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP