# GenerateBeta: GenerateBeta__question3.7(Statistical Computing with R) In zhengdat/StatComp18049: Homework of statistical computation

## Description

question3.7(Statistical Computing with R):Write a function to generate a random sample of size n from the Beta(a, b) distribution by the acceptance-rejection method. Generate a random sample of size 1000 from the Beta(3,2) distribution. Graph the histogram of the sample with the theoretical Beta(3,2) density superimposed

Here we use Acceptance-Rejection Method to generate a random sample, and And draw the density function of beta distribution and compare them.

## Usage

 `1` ```GenerateBeta(n, a, b) ```

## Arguments

 `n` The sise of random sample we want to generateBeta `a` The first parameter of Beta distribution function `b` The second parameter of Beta distribution function

## Value

y The random sample has been Generated, which is a vector

## Examples

 ```1 2 3 4``` ```y<-GenerateBeta(1000,3,2) hist(y,prob = TRUE,ylim=c(0,2)) x <- seq(0, 1, 0.01) lines(x, x^2*(1-x)/beta(3,2)) ```

zhengdat/StatComp18049 documentation built on May 29, 2019, 8:33 a.m.