Difference between revisions of "Beta distributions"
From Organic Design wiki
m (Caretaker: Format links) |
m (Caretaker: Format links, Format cat links, Format headings) |
||
Line 1: | Line 1: | ||
[[Category:R]] | [[Category:R]] | ||
− | =Beta distributions= | + | |
+ | = Beta distributions = | ||
For details on the beta distribution see [[WikiPedia:Beta distribution]]. The parameters p, and q | For details on the beta distribution see [[WikiPedia:Beta distribution]]. The parameters p, and q | ||
are α & β in the Wikipedia article formula. The x axis range is from 0 to 1, the range for probabilities | are α & β in the Wikipedia article formula. The x axis range is from 0 to 1, the range for probabilities | ||
Line 7: | Line 8: | ||
uniform distributions β(1,1) right through to symmetric or skewed distributions, or even U shaped distributions. | uniform distributions β(1,1) right through to symmetric or skewed distributions, or even U shaped distributions. | ||
− | ==R programming language== | + | == R programming language == |
For help on functions which create/manipulate beta distributions see; | For help on functions which create/manipulate beta distributions see; | ||
<table class=document-code><tr><td> | <table class=document-code><tr><td> | ||
Line 22: | Line 23: | ||
</table> | </table> | ||
− | ==R code example 1== | + | == R code example 1 == |
Lets generate a beta distribution using the ''rbeta'' built in R function. | Lets generate a beta distribution using the ''rbeta'' built in R function. | ||
<table class=document-code><tr><td> | <table class=document-code><tr><td> | ||
Line 37: | Line 38: | ||
Notice α and β are less than one, so the plot is U shaped, as described in [[Wikipedia:Beta distribution#Shapes|Wikipedia:Beta distribution#Shapes]]. | Notice α and β are less than one, so the plot is U shaped, as described in [[Wikipedia:Beta distribution#Shapes|Wikipedia:Beta distribution#Shapes]]. | ||
− | ==Symmetry of α Β== | + | == Symmetry of α Β == |
==R code example 2== | ==R code example 2== | ||
<table class=document-code><tr><td> | <table class=document-code><tr><td> | ||
Line 53: | Line 54: | ||
</table> | </table> | ||
− | ==See also== | + | == See also == |
[[BetaDistributions.R]] | [[BetaDistributions.R]] |
Revision as of 20:12, 3 November 2006
Contents
Beta distributions
For details on the beta distribution see WikiPedia:Beta distribution. The parameters p, and q are α & β in the Wikipedia article formula. The x axis range is from 0 to 1, the range for probabilities
Beta distributions have many shapes depending on the parameters. Their flexibility makes them useful for modelling uniform distributions β(1,1) right through to symmetric or skewed distributions, or even U shaped distributions.
R programming language
For help on functions which create/manipulate beta distributions see;
?beta # or help(beta) ?rbeta # or help(rbeta) |
Usage examples are provided at;
example(beta) example(rbeta) example(dbeta) example(pbeta) example(qbeta) |
R code example 1
Lets generate a beta distribution using the rbeta built in R function.
quartz() # Alter the parameters n <- 1000 # Number of observations p <- 0.1 q <- 0.1 x <- rbeta(n, shape1= p, shape2=q) breaks <- seq(0,1, length=21) hist(x, breaks=breaks, freq=FALSE, main=paste("p=",p, ", q=", q, sep="")) lines(density(x, adjust=0.4), col="red") |
Notice α and β are less than one, so the plot is U shaped, as described in Wikipedia:Beta distribution#Shapes.
Symmetry of α Β
R code example 2
quartz() # Alter the parameters n <- 10000 # Number of observations for(i in 1:50) { p <- q <- i x <- rbeta(n, shape1= p, shape2=q) breaks <- seq(0,1, length=21) hist(x, breaks=breaks, freq=FALSE, main=paste("p=",p, ", q=", q, sep="")) lines(density(x, adjust=0.4), col="red") Sys.sleep(1) } |