Message Boards Message Boards

0
|
5630 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Compute and use the gaussian variance formula?

Posted 7 years ago

Hey,

I've already made a similar discussion, but since I do not get any answers there, I decided to start a new one with more details. Please apologize that.

I have the function

El[k_ , l_, d_] := k * l / (0.25*d^2*Pi)

and defined the gaussian variance formula

Eld [k_, l_, d_, kd_, ld_, dd_] := 
 Sqrt[kd (Derivative[1, 0, 0][El])^2 + 
   ld (Derivative[1, 0, 0][El])^2 + dd (Derivative[1, 0, 0][El])^2]

It works pretty well for El... El[1,2,3] (just some random numbers for the variables to try it out) gives me 0.282942.

However, Eld[1, 2, 3, 4, 5, 6] doesn't work, which makes sense because Eld can't give k,l and d to El. However, I need to first derivate the function by hand (or wolfram alpha) and then write the full code into Eld. Do you know how to solve this issue?

Thank you,

Tobias

POSTED BY: Epsilon Tau
4 Replies

Jim did a very elegant matrix reformulation of your problem. To help you understand what he did you could have fixed your formula as follows:

Eldp[k_, l_, d_, kd_, ld_, dd_] := 
 Sqrt[kd (Derivative[1, 0, 0][El][k, l, d])^2 + 
   ld (Derivative[0, 1, 0][El][k, l, d])^2 + 
   dd (Derivative[0, 0, 1][El][k, l, d])^2]

Note that El is a pure function -- you gave it no arguments. Also, your partial derivatives were specified wrong -- the Derivative[0,1,0] means derivative with respect to the second variable -- yours were all wrt the first variable. Jim created a vector of the partial derivatives in one shot by doing

D[El[vk, vl, vd], {{vk, vl, vd}}]) 

you could do each one individually by doing this

D[El[vk, vl, vd], vk]) 

he used temporary variables (vk,vl,vd) so values would not be substituted, getting your derivatives as expressions of vk,vl, and vd but then assigned the values with the rules

/. vk->k

etc.

he then created a diagonal matrix of your three coefficients kd,ld,dd, and took a dot product.

Hope this helps.

POSTED BY: Neil Singer
Posted 7 years ago
Posted 7 years ago

I have not heard of the term "gaussian variance" before but I suspect you mean that you want to use the Delta Method (as it is known to statisticians) which is equivalent to the Propagation of Error (as it is known to some engineers and physicists). If k, l, and d are statistically independent of each other (or at least their covariances are zero), then you could use the following:

El[k_, l_, d_] := k l/(d^2 \[Pi]/4)
Eld[k_, l_, d_, kd_, ld_, dd_] := Module[{vk, vl, vd, f, \[CapitalSigma]},
  f = (D[El[vk, vl, vd], {{vk, vl, vd}}]) /. {vk -> k, vl -> l,  vd -> d};
  \[CapitalSigma] = DiagonalMatrix[{kd, ld, dd}];
  Sqrt[FullSimplify[f.\[CapitalSigma].f]]]

Eld[k, l, d, kd, ld, dd]
(* (4 Sqrt[(4 dd k^2 l^2+d^2 (kd l^2+k^2 ld))/d^6])/\[Pi] *)
Eld[1, 2, 3, 4, 5, 6]
(* (4 Sqrt[95/3])/(9 \[Pi]) *)
POSTED BY: Jim Baldwin
Posted 7 years ago

Thanks a lot, it works perfectly! Now I'm trying to understand what the hell you did there :D But I'm sure I'll understand it with a some hours of work so that I can solve problems like this in the future myself.

POSTED BY: Epsilon Tau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract