0
$\begingroup$

enter image description here

I have a crazy output. I already tried the N[] function. All it does is condense the inputs. Any idea of how to have a numerical output from the code?

$\endgroup$
  • 8
    $\begingroup$ Please provide actual code rather than an image of code. $\endgroup$ – Daniel Lichtblau Oct 3 '18 at 17:36
1
$\begingroup$
Clear["Global`*"]

dist = NormalDistribution[a, b];

$Assumptions = DistributionParameterAssumptions[dist]

(* a ∈ Reals && b > 0 *)

cdf[q_] = CDF[dist, q];

If I have read your expression properly, it can be written more compactly as

expr1 = (4*(cdf[1] - cdf[0]) + 6*(cdf[2] - cdf[1]) +
      8*(cdf[3] - cdf[2]) + 10*(cdf[4] - cdf[3]) +
      12*(cdf[5] - cdf[4]))/(cdf[5] - cdf[0]) // FullSimplify;

And even more so as

expr2 = Total[
    2 (# + 1)*(cdf[#] - cdf[# - 1]) & /@ Range[5]]/(cdf[5] - cdf[0]) // 
  FullSimplify

(* (2 (-6 Erf[(-5 + a)/(Sqrt[2] b)] + Erf[(-4 + a)/(Sqrt[2] b)] + 
     Erf[(-3 + a)/(Sqrt[2] b)] + Erf[(-2 + a)/(Sqrt[2] b)] + 
     Erf[(-1 + a)/(Sqrt[2] b)] + 2 Erf[a/(Sqrt[2] b)]))/(-1 + 
   Erf[a/(Sqrt[2] b)] + Erfc[(-5 + a)/(Sqrt[2] b)]) *)

Verifying that expr1 and expr2 are identical

expr1 === expr2

(* True *)

Using your assignments

a = (1/2*Erfc[1/Sqrt[2]]*x); 
b = -q*Log[2, q] - (1 - q)*Log[2, 1 - q];
q = a/x;
x = 4;

expr2 // N

(* 4.70403 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.