How to generate random values from tlocationscale distributions ?

5 ビュー (過去 30 日間)
Rita
Rita 2016 年 7 月 15 日
回答済み: Anudeep Kumar 2025 年 4 月 22 日
I would like to create some random numbers with tlocationscale distribution.I am not sure how to do it. Thanks for any help.

回答 (1 件)

Anudeep Kumar
Anudeep Kumar 2025 年 4 月 22 日
Hey Rita,
In MATLAB, you can generate random numbers from a t location-scale distribution using the “makedist” and “random” functions.
Here is a sample code on how to achieve the goal:
% Parameters
mu = 0; % Location parameter
sigma = 1; % Scale parameter
nu = 5; % Degrees of freedom
N = 1000; % Number of random numbers
% Create the t location-scale distribution object
pd = makedist('tLocationScale', 'mu', mu, 'sigma', sigma, 'nu', nu);
% Generate random numbers
r = random(pd, N, 1);
% Display histogram
histogram(r, 30);
title('Random numbers from t location-scale distribution');
You can refer to this documentation for detail about the function and how you can modify it for your use case:
Hope it helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by