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?
Coefficient[fun[\[Mu], \[Sigma], c, o], #] & /@ vars
$\endgroup${oo, nn,mm} = ...
at the front. $\endgroup$vars.mm.vars + nn.vars + oo == fun[\[Mu], \[Sigma], c, o] // Simplify
would output "true". There is something that still escapes me... $\endgroup$