Difference between revisions of "Beta distributions"

From Organic Design wiki
m
m (R programming language)
Line 26: Line 26:
 
  x <- rbeta(n, shape1= p, shape2=q)
 
  x <- rbeta(n, shape1= p, shape2=q)
 
  breaks <- seq(0,1, length=21)
 
  breaks <- seq(0,1, length=21)
  hist(x, breaks=breaks)
+
  hist(x, breaks=breaks, freq=FALSE)
 +
lines(density(x, adjust=0.3), col="red")
 
</table>
 
</table>
 +
 
==See also==
 
==See also==
 
[[BetaDistributions.R]]
 
[[BetaDistributions.R]]
  
 
[[Category:R]]
 
[[Category:R]]

Revision as of 03:18, 2 August 2006

Beta distributions

For details on the beta distribution see WikiPedia:Beta distribution.

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.

# 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.3), col="red")

See also

BetaDistributions.R