MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Discrete probablitiy distributions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16379] Re: [mg16273] Discrete probablitiy distributions
  • From: "Tomas Garza" <tgarza at mail.internet.com.mx>
  • Date: Thu, 11 Mar 1999 02:16:49 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Bjorn Leonardz wrote:

> I have been trying to find a good way of making Mathematica help me
> prepare some lecture notes in elementary probability. This is what I
> want to achieve:
>
> Given the probability function for a discrete random variable, e.g in
> the form of a list of probabilities
>
> 1. Plot the probability function (I can do this with ListPlot or
> BarChart)
>
> 2. Plot the cumulative probability function.

Hi Bjorn,

Suppose you have the list origprobs whose elements are {ai,pi}, for i =
1,...,m,
where pi is the probability of value ai.

Needs["Graphics`Graphics`"];
Needs["Statistics`DataManipulation`"];

You may plot the probability function with BarChart, as you say, using

BarChart[Transpose[{Transpose[origprobs][[2]],Transpose[origprobs][[1]]}]]

Use "CumulativeSums" from the add-on Statistics`DataManipulation` and get

BarChart[Transpose[{CumulativeSums[Transpose[origprobs][[2]]],Transpose[orig
probs][[1]]}]]

You can also plot the distribution function (i.e. the cumulative probability
function) in the traditional (and more useful) way as follows:

distfunc =
Interpolation[Transpose[{Transpose[origprobs][[1]],CumulativeSums[Transpose[
origprobs][[2]]]}], InterpolationOrder->0}

and then

Plot[distfunc[x, {x,Min[a1],Max[ai]}]

Good luck,
Tomas Garza
Mexico City



  • Prev by Date: Re: Position of element in a list
  • Next by Date: BHHH algorithm
  • Previous by thread: Re: Discrete probablitiy distributions
  • Next by thread: Re: Discrete probablitiy distributions