plot - Can't integrate the subtraction of two Gaussian CDFs [Wolfram Mathematica] [SOLVED] -



plot - Can't integrate the subtraction of two Gaussian CDFs [Wolfram Mathematica] [SOLVED] -

i have function product composed 3 (k) factors . each factor subtraction of 2 gaussian cdf random variables r , l. these random variables defined according 4 parameters.

the code below shows how plot main function (according 2 independent variables d , e) , how random variables calculated

sigma = 1; k = 3; priors = {}; appendto[priors, 1/k + e]; do[appendto[priors, 1/k - e/(k - 1)], {c, 2, k}]; l[priors_, sigma_, d_, i_] := do[ maxval = -infinity; do[ val = (2*sigma^2*log[priors[[i]]/priors[[j]]] + d^2 (j^2 - i^2 + 2 (i - j)))/(2 (j - i) d); if[val > maxval, maxval = val, null]; , {j, 1, - 1}]; return[maxval]; , {1}]; r[priors_, sigma_, d_, i_] := do[ minval = infinity; do[ val = (2*sigma^2*log[priors[[j]]/priors[[i]]] + d^2 (i^2 - j^2 + 2 (j - i)))/(2 (i - j) d); if[val < minval, minval = val, null]; , {j, + 1, k}]; return[minval]; , {1}]; print[ plot3d[ product[ if[r[priors, sigma, d, c] < l[priors, sigma, d, c], 0, (cdf[normaldistribution[(c - 1) d, sigma], r[priors, sigma, d, c]] - cdf[normaldistribution[(c - 1) d, sigma], l[priors, sigma, d, c]])] , {c, 1, k}] , {d, 0.01, 5} , {e, -1/k, 1 - 1/k}, plotrange -> {all, all, all}, axeslabel -> automatic]];

now, want integrate function on d (in same part plot3d, d=0.01-5) , plot results according independent variable e.

below code i've used.

print[ plot[ integrate[ product[ if[r[priors, sigma, d, c] < l[priors, sigma, d, c], 0, (cdf[normaldistribution[(c - 1) d, sigma], r[priors, sigma, d, c]] - cdf[normaldistribution[(c - 1) d, sigma], l[priors, sigma, d, c]])] , {c, 1, k}] , {d, 0.01, 5}] , {e, -1/k, 1 - 1/k}, plotrange -> {all, all}, axeslabel -> automatic]];

however, resulting plot not expect. it's constant , in 3d plot can seen cannot happen. know happening , obtain real integration of function? in advance.

when compute val within functions l , r result symbolic (because e not defined ). logical val < minval indeterminate, , result minval never set (so l , r homecoming infinity every time )

(cleaned couple of other things well.. )

sigma = 1; k = 3; priors = join[ {1/k + e} , table[1/k - e/(k - 1) , {c, 2, k} ] ]; l[priors0_, sigma_, d_, i_, e0_] := module[{priors, maxval, val, e}, do[maxval = -infinity; priors = priors0 /. e -> e0 ; do[val = (2*sigma^2*log[priors[[i]]/priors[[j]]] + d^2 (j^2 - i^2 + 2 (i - j)))/(2 (j - i) d); if[val > maxval, maxval = val];, {j, 1, - 1}];, {1}]; maxval]; r[priors0_, sigma_, d_, i_, e0_] := module[{priors, maxval, val, e}, priors = priors0 /. e -> e0; min[table[(2*sigma^2*log[priors[[j]]/priors[[i]]] + d^2 (i^2 - j^2 + 2 (j - i)))/(2 (i - j) d), {j, + 1, k}]]]; g[d_?numericq, c_, e_] := product[if[r[priors, sigma, d, c, e] < l[priors, sigma, d, c, e], 0, (cdf[normaldistribution[(c - 1) d, sigma], r[priors, sigma, d, c, e]] - cdf[normaldistribution[(c - 1) d, sigma], l[priors, sigma, d, c, e]])], {c, 1, k}]; plot[nintegrate[g[d, c, e], {d, 0.01, 5}], {e, -1/k, 1 - 1/k}, plotrange -> {all, all}, axeslabel -> automatic]

plot wolfram-mathematica gaussian integrate

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -