EZ Study

Actuarial Biology Chemistry Economics Calculators Confucius Engineer

6. Intuitive explanation for Beta distribution

0. Intro. to Bayesian   1. Bayesian VS. Frequentist   2. Metropolis Algorithm Example   3.Gibbs Sampler Example
4. Bayesian Proc in SAS     5. Intuitive example for Beta distri.     6. Trick to compare two baseball players

Frequently Asked Question: Say, we have two Baseball Players A and B, both have batting Average 33.3%; as you can see in the following table, both are excellent, right? Which one is better? and Statistics Why?
Player Hits Miss Hit %
BaseBall Player A   3 6 33.3%
BaseBall Player B   6 12 33.3%
        data beta1;
        do i=0 to 1 by 0.01;
            /*var1=rand('beta',2,6); generate random Beta*/

        label var1="Overall Baseball Batting Distri."
                var2="Baseball A : Hit 3 out of 9"
                var3="Baseball B : Hit 6 out of 18"; run;

        symbol1 interpol=spline width=2 value=triangle c=steelblue;
        symbol2 interpol=spline width=2 value=circle c=indigo;
        symbol3 interpol=spline width=2 value=square c=green;
        axis2 label=("Beta Density" justify=right "For different beta" );
        legend1 label=none value=(tick=0.1 );

        proc gplot data=beta1;
        plot var1*i var2*i var3*i /overlay
        vaxis=axis2 legend=legend1; run;

Example of fitting a beta curve
        data Robots;
        input Length @@;
        10.147 10.070 10.032 10.042 10.102     10.034 10.143 10.278 10.114 10.127
        10.211 10.122 10.031 10.322 10.187     10.094 10.067 10.094 10.051 10.174
        ; run;

        title 'Fitted a Beta Distribution';
        proc univariate data=Robots;
        histogram Length / /* theta: the begining pooint */
        beta(theta=10 scale=0.5 color=red fill) /*scale: the width*/
        href = 10 hreflabel = 'Lower Bound'
        lhref = 2 vaxis = axis1;
        axis1 label=(a=90 r=0);
        inset n = 'Sample Size'
        beta / pos=ne cfill=blank; run;

        /*We can also KDE procedure to estimate the density graph*/
        ods graphics on;
        proc kde data=beta1;
            univar var1/ plots=(density histogram histdensity); run;

Related links:
Back to Bayesian Statistics Tutorial home     Math Humor Home    Statistics Home
Continue to Time Series Modeling tutorial home     Homepage