Message Boards Message Boards

0
|
5608 Views
|
5 Replies
|
6 Total Likes
View groups...
Share
Share this post:

VARIANCE and PDF

Posted 3 years ago

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?

Thank you all.

Attachment

Attachments:
5 Replies
Posted 3 years ago

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

(* 9/4 *)

The sample mean is found with

Mean[x]
POSTED BY: Jim Baldwin

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".

If you, for example, make a list of numbers:

list = {600, 470, 170, 430, 300} ;

and calculate the variance:

Variance[list]

it returns: 27130

While a Variance with "N" numbers would be: 21704

Therefore, for such result, the syntax would be:

N[Variance[list]*((n - 1)/n)]
Posted 3 years ago

You are correct. I really messed up on that. Sorry.

I have corrected my response.

POSTED BY: Jim Baldwin

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.

PDF[TruncatedDistribution[{0, 1}, ExponentialDistribution[1]], x]

You will see that the PDF is basically some constant multiplied by Exp[-x].

So now life is easy. You can compute the Variance.

Variance[TruncatedDistribution[{0, 1}, ExponentialDistribution[1]]]

You can plot the CDF and PDF.

Plot[CDF[TruncatedDistribution[{0, 1}, ExponentialDistribution[1]], 
  x], {x, -1, 2}]

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.

Variance[ProbabilityDistribution[
  c Exp[-x] /. 
   First[Solve[Integrate[c Exp[-x], {x, 0, 1}] == 1, c]], {x, 0, 1}]]
POSTED BY: Seth Chandler

Thank you, sir. How about the Variance function? What if I wanted a function that calculates as follows:

Attachment

Attachments:
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