Representing continuous probability distributions

后端 未结 10 1960
天命终不由人
天命终不由人 2021-01-30 14:27

I have a problem involving a collection of continuous probability distribution functions, most of which are determined empirically (e.g. departure times, transit times). What I

相关标签:
10条回答
  • 2021-01-30 15:24

    If you want some fun, try representing them symbolically like Maple or Mathemetica would do. Maple uses directed acyclic graphs, while Matematica uses a list/lisp like appoach (I believe, but it's been a loooong time, since I even thought about this).

    Do all your manipulations symbolically, then at the end push through numerical values. (Or just find a way to launch off in a shell and do the computations).

    Paul.

    0 讨论(0)
  • 2021-01-30 15:26

    Another suggestion is to use kernel densities. Especially if you use Gaussian kernels, then they can be relatively easy to work with... except that the distributions quickly explode in size without care. Depending on the application, there are additional approximation techniques like importance sampling that can be used.

    0 讨论(0)
  • 2021-01-30 15:27

    Some initial thoughts:

    First, Mathematica has a nice facility for doing this with exact distributions.

    Second, representation as histograms (ie, empirical PDFs) is problematic since you have to make choices about bin size. That can be avoided by storing a cumulative distribution instead, ie, an empirical CDF. (In fact, you then retain the ability to recreate the full data set of samples that the empirical distribution is based on.)

    Here's some ugly Mathematica code to take a list of samples and return an empirical CDF, namely a list of value-probability pairs. Run the output of this through ListPlot to see a plot of the empirical CDF.

    empiricalCDF[t_] := Flatten[{{#[[2,1]],#[[1,2]]},#[[2]]}&/@Partition[Prepend[Transpose[{#[[1]], Rest[FoldList[Plus,0,#[[2]]]]/Length[t]}&[Transpose[{First[#],Length[#]}&/@ Split[Sort[t]]]]],{Null,0}],2,1],1]

    Finally, here's some information on combining discrete probability distributions:

    http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/Chapter7.pdf

    0 讨论(0)
  • 2021-01-30 15:29

    Is there anything that stops you from employing a mini-language for this?

    By that I mean, define a language that lets you write f = x + y and evaluates f for you just as written. And similarly for g = x * z, h = y(x), etc. ad nauseum. (The semantics I'm suggesting call for the evaluator to select a random number on each innermost PDF appearing on the RHS at evaluation time, and not to try to understand the composted form of the resulting PDFs. This may not be fast enough...)


    Assuming that you understand the precision limits you need, you can represent a PDF fairly simply with a histogram or spline (the former being a degenerate case of the later). If you need to mix analytically defined PDFs with experimentally determined ones, you'll have to add a type mechanism.


    A histogram is just an array, the contents of which represent the incidence in a particular region of the input range. You haven't said if you have a language preference, so I'll assume something c-like. You need to know the bin-structure (uniorm sizes are easy, but not always best) including the high and low limits and possibly the normalizatation:

    struct histogram_struct {
      int bins; /* Assumed to be uniform */
      double low;
      double high;
      /* double normalization; */    
      /* double *errors; */ /* if using, intialize with enough space, 
                             * and store _squared_ errors
                             */
      double contents[];
    };
    

    This kind of thing is very common in scientific analysis software, and you might want to use an existing implementation.

    0 讨论(0)
提交回复
热议问题