Open In App

Compute Randomly Drawn Chi Square Density in R Programming - rchisq() Function

Last Updated : 25 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
rchisq() function in R Language is used to compute random chi square density for a set of values.
Syntax: rchisq(N, df) Parameters: N: Sample Size df: Degree of Freedom
Example 1: Python3 1==
# R program to generate 
# random chi square density points

# Setting seed for
# random number generation
set.seed(1000)

# Set sample size
N <- 20

# Calling rchisq() Function
y <- rchisq(N, df = 10)
y 
Output:
 [1]  7.208082 11.236799  3.780669  5.972266 12.174243 14.308333  3.886482
 [8]  4.117081 13.015581  3.864009  8.494487 17.713528  2.411329  7.096494
[15]  4.546996 11.542960  9.683502  9.073933 11.120782  9.193626
Example 2: Python3 1==
# R program to generate 
# random chi square density points

# Setting seed for
# random number generation
set.seed(1000)

# Set sample size
N <- 500

# Calling rchisq() Function
y <- rchisq(N, df = 10)

# Plotting graph
plot(y)
Output:

Next Article
Article Tags :

Similar Reads