Hello all,
I am struggling to find the correct function for Variance. It does exist, but it is the SAMPLE variance, i.e. the (n-1) denominator.
I need to find (if it does exist) the SIGMA variance, i.e. the one with just N at the denominator.
Anyone knows ?
Plus, suppose I wanted to plot the pdf f(x) =ce^-x (0<x<1) and find the CDF and its expected value. How would I proceed?
The concept you are missing is that you need to define a probability distribution. The PDF is not the same thing as the distribution itself. Basically, you describe a TruncatedDistribution of an ExponentialDistribution. So you could write this as follows. First, check that my assertion is correct.
You could do this even if you did not recognize the distribution as a truncated exponential. The code below shows how. The key is to wrap up the computed PDF inside ProbabilityDistribution.
Your first question seems to have nothing to do with your second question. (Maybe that is what you intended.)
Note: Corrected response thanks to Mauro Benjamin Mistretta.
For a sample of size n, the sample variances you describe with the denominator being n-1 and with the denominator of n are found in the following manner:
(* Sample *)
x = {1, 2, 4, 5, 1, 2};
n = Length[x]
(* 6 *)
(* Sample variance with n-1 in the denominator *)
s2 = Variance[x]
(* 27/10 *)
(* Sample variance with n in the denominator *)
variance = Variance[x] (n-1)/n
Thank you, Jim.
Yes: the two questions are totally unrelated.
And thanks for your suggestions!
Please note, though, that what you said: “In other words, Mathematica does not have a specific formula for the sample variance with a denominator of n−1.” is wrong.
The Mathematica function “Variance” indeed holds “n-1” (the Bessel’s variance) at the denominator, by default…I thought there was another function with “N”.