0
$\begingroup$

Suppose I have a PDF with mean a and standard deviation b defined as below. As the value of k increases, a should decrease, while b should also decrease. This should cause a decrease in the output, but for some reason, there is an increase. Even when I set the value of b constant, and simply let a decrease, the output increases, which should not happen. Any thoughts?

a=1/2Erfc[k/Sqrt[2]] * x
k=0.2
b= -q Log[2, q] - (1 - q) Log[2, 1 - q]
q=a/x
x=7

N[ 
x/(
   (CDF[NormalDistribution[a,b],8]-CDF[NormalDistribution[a,b],1])/
   (CDF[NormalDistribution[a,b],1]-CDF[NormalDistribution[a,b],0])
  )
 ]
$\endgroup$
2
$\begingroup$

This is really just a math problem. Mathematica is providing the correct output based on your input.

The output you're asking for (in shorthand) is x/((CDF[8]-CDF1)/(CDF[8]-CDF1)). This can be rewritten as (CDF[8]-CDF[0]) * x / (CDF[8]-CDF1). The numerator (CDF[8]-CDF[0]) goes somewhat slowly to 1/2 as k increases. The denominator (CDF[8]-CDF1) rapidly goes to zero. When you have a small number in the denominator and a much larger number in the numerator, it explodes to infinity.

As k goes to zero, your output should converge to 7.0421, since the numerator and denominator are basically the same.

Here is some code to see what happens:

x = 7;
a[k_] := 1/2 Erfc[k/Sqrt[2]]*x
q[k_] := a[k]/x
b[k_] := -q[k] Log[2, q[k]] - (1 - q[k]) Log[2, 1 - q[k]]
cdf[val_, k_] := CDF[NormalDistribution[a[k], b[k]], val]

(* Let's see what happens to your numerator and denominator *)
Plot[
 {cdf[8, k] - cdf[0, k],
  cdf[8, k] - cdf[1, k]},
 {k, 0, 3},
 AxesLabel -> {"k", "Value"},
 PlotLegends -> 
  Placed[{"Numerator", 
    "Denominator"}, {Scaled[{0.95, 0.25}], {1, 0}}]]

(* Let's see what happens to the mean and standard deviation as k increases *)
Plot[
 {a[k], b[k]},
 {k, 0, 3},
 AxesLabel -> {"k", "Value"},
 PlotLegends -> 
  Placed[{"Mean (a)", 
    "Standard Deviation (b)"}, {Scaled[{0.9, 0.9}], {1, 1}}],
 PlotRange -> Full]

You should see that the denominator (yellow curve) rapidly drops to zero, meaning your output value will explode to infinity.

Plot of numerator and denominator.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Yes, you are correct. I have realized that I am asking for the wrong output. Thank you for helping! $\endgroup$ – sde7 Nov 24 '18 at 18:33
  • $\begingroup$ No problem, glad it worked out for you! $\endgroup$ – MassDefect Nov 25 '18 at 1:56

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.