Difference between revisions of "Beta distributions"

From Organic Design wiki
(Shape details)
(R programming language: symmetric visual for loop)
Line 34: Line 34:
 
  lines(density(x, adjust=0.4), col="red")
 
  lines(density(x, adjust=0.4), col="red")
 
</table>
 
</table>
 +
 +
==Symmetry of &alpha; &Beta;==
 +
quartz()
 +
# Alter the parameters
 +
n <- 1000 # 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")
 +
}
  
 
==See also==
 
==See also==

Revision as of 03:50, 2 August 2006

Beta distributions

For details on the beta distribution see WikiPedia:Beta distribution. Notice that thee distribution is symmetric for the parameters p, and q (α & β in the Wikipedia article formula), and that the x axis range is from 0 to 1, a probability.

Beta distributions have many shapes depending on the parameters. Their flexibility makes them useful for modelling uniform distributions &Beta(1,1) right through to symmetric or skewed 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)

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)
lines(density(x, adjust=0.4), col="red")

Symmetry of α Β

quartz()
# Alter the parameters
n <- 1000 # 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")
}

See also

BetaDistributions.R