Related Articles

# Create a Random Sequence of Numbers within t-Distribution in R Programming – rt() Function

• Last Updated : 19 Jun, 2020

`rt()` function in R Language is used to create a random sequence of values from Student t-distribution.

Syntax: rt(n, df, ncp)

Parameters:
n: Number of observations
df: Degree of Freedom
ncp: Numeric vector of non-centrality parameters.

Example 1:

 `# R Program to create random sequence``# from t distribution`` ` `# Calling rt() Function``rt(``15``, ``2``)``rt(``15``, ``1``)`

Output:

``` [1]  2.09851925 -1.76883434 -0.56019367  0.23263458  1.02778818 -0.82274015
[7] -1.33110401  4.19230931  0.80622707  0.02468189 -4.00469465  0.02974788
[13]  1.28649412 -0.19235704  0.21665196
[1]   2.21010764 -11.70663704  -1.00452125   2.07828752   1.95781361
[6]  -0.53603661   0.02068073  -1.32464307 -49.93080321   0.82594818
[11]  -0.46109805  -0.18965787   0.60498953  -0.44659619  -0.08968020
```

Example 2:

 `# R Program to create random sequence``# from t distribution`` ` `# Calling rt() Function``rt(``5``, ``1``, ``1``:``5` `*` `5``)``rt(``5``, ``2``, ``1``:``10``)`

Output:

```[1] 23.88663 20.26813 62.95437 14.59003 20.58296
[1]  0.1745755  4.5298859  1.1175184  7.4660938 45.1399588
```
My Personal Notes arrow_drop_up