Random numbers from discrete uniform distribution (2024)

Random numbers from discrete uniform distribution

collapse all in page

Syntax

r = unidrnd(n)

r = unidrnd(n,sz1,...,szN)

r = unidrnd(n,sz)

Description

example

r = unidrnd(n) generates random numbers from the discrete uniform distribution specified by its maximum value n.

n can be a scalar, vector, matrix, or multidimensional array.

example

r = unidrnd(n,sz1,...,szN) generates an array of random numbers from the discrete uniform distribution with the scalar maximum value n, where sz1,...,szN indicates the size of each dimension.

example

r = unidrnd(n,sz) generates an array of random numbers from the discrete uniform distribution with the scalar maximum value n, where vector sz specifies size(r).

Examples

collapse all

Array of Random Numbers from Several Discrete Uniform Distributions

Open Live Script

Generate an array of random numbers from the discrete uniform distributions. For each distribution, specify its maximum value.

Specify the maximum values of the distributions.

Generate random numbers from the discrete uniform distributions.

r = unidrnd(n)
r = 1×10 1 10 3 29 26 5 17 39 78 88

Array of Random Numbers from One Discrete Uniform Distribution

Open Live Script

Generate an array of random numbers from one discrete uniform distribution. Here, the maximum value n is a scalar.

Use the unidrnd function to generate random numbers from the discrete uniform distribution with the maximum value 100. The function returns one number.

R_scalar = unidrnd(100)
R_scalar = 82

Generate a 2-by-3 array of random numbers from the same distribution by specifying the required array dimensions.

R_array = unidrnd(100,2,3)
R_array = 2×3 91 92 10 13 64 28

Alternatively, specify the required array dimensions as a vector.

R_array = unidrnd(100,[2,3])
R_array = 2×3 55 97 98 96 16 96

Input Arguments

collapse all

nMaximum value
positive integer | array of positive integers

Maximum value, specified as a positive integer or array of positive integers.

Example: unidrnd(10)

Data Types: single | double

sz1,...,szNSize of each dimension (as separate arguments)
integers

Size of each dimension, specified as separate arguments of integers. For example, specifying 5,3,2 generates a 5-by-3-by-2 array of random numbers from the discrete uniform distribution.

If n is an array, then the specified dimensions sz1,...,szN must match the dimensions of n.

  • If you specify a single value sz1, then r is a square matrix of size sz1-by-sz1.

  • If the size of any dimension is 0 or negative, then r is an empty array.

  • Beyond the second dimension, unidrnd ignores trailing dimensions with a size of 1. For example, unidrnd(n,3,1,1,1) produces a 3-by-1 vector of random numbers.

Example: 5,3,2

Data Types: single | double

szSize of each dimension (as a row vector)
row vector of integers

Size of each dimension, specified as a row vector of integers. For example, specifying [5 3 2] generates a 5-by-3-by-2 array of random numbers from the discrete uniform distribution.

If n is an array, then the specified dimensions sz must match the dimensions of n.

  • If you specify a single value [sz1], then r is a square matrix of size sz1-by-sz1.

  • If the size of any dimension is 0 or negative, then r is an empty array.

  • Beyond the second dimension, unidrnd ignores trailing dimensions with a size of 1. For example, unidrnd(n,[3 1 1 1]) produces a 3-by-1 vector of random numbers.

Example: [5 3 2]

Data Types: single | double

Output Arguments

collapse all

r — Random numbers from discrete uniform distribution
scalar value | array of scalar values

Random numbers from the discrete uniform distribution, returned as a scalar value or an array of scalar values.

Data Types: single | double

Alternative Functionality

  • unidrnd is a function specific to discrete uniform distribution. Statistics and Machine Learning Toolbox™ also offers the generic function random, which supports various probability distributions. To use random, specify the probability distribution name and its parameters. Note that the distribution-specific function unidrnd is faster than the generic function random.

  • To generate random numbers interactively, use randtool, a user interface for random number generation.

Extended Capabilities

This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a

See Also

random | unidpdf | unidcdf | unidinv | unidstat

Topics

  • Uniform Distribution (Discrete)

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Random numbers from discrete uniform distribution (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Random numbers from discrete uniform distribution (2024)
Top Articles
Test Monitor Dell U3415W - Prad.de
Dell UltraSharp U3415W Review
Blackstone Launchpad Ucf
Craigslist Centre Alabama
Costco Fuel Price Today Near Me
Jak zgłosić awarię i brak energii elektrycznej w Twoim mieszkaniu lub domu? - ENERGA-OPERATOR SA
Busted Newspaper Longview Texas
Bingo Bling Promo Code 2023
Roy12 Mods
Optum Primary Care - Winter Park Aloma
Chukchansi Webcam
Mandy Sacs On BLP Combine And The Vince McMahon Netflix Documentary
Indicafans
Thompson Center Thunderhawk Parts
John W Creasy Died December 16 2003
C.J. Stroud und Bryce Young: Zwei völlig unterschiedliche Geschichten
Sarah Dreyer Obituary
Oriellys Bad Axe
Equity Livestock Altoona Market Report
Restaurant-grevesmuehlen in Freiburg im Breisgau
Nsu Occupational Therapy Prerequisites
Kate Spade OUTLET • bis 70%* im Sale | Outletcity Metzingen
630251.S - CCB-PWRIO-05 - Vision Systems - Vision Systems In-Sight, Cognex - InSight 2800 Series - Accessories Cables / Brackets IS28XX -
Clarksville.craigslist
ASVAB Test: The Definitive Guide (updated 2024) by Mometrix
Fishweather
The Professor Tape 1 Prof Snow Myvidster
Weather Arlington Radar
Premium Car Rental in Vancouver
Sdn Upstate 2023
Marisa Jacques Bio
Lenscrafters Westchester Mall
Walgreens Pharmacy On Jennings Station Road
Twitter Jeff Grubb
2014 Chevy Malibu Belt Diagram
Maatschappij- en Gedragswetenschappen: van inzicht naar impact
Linktree Teentinyangel
Acadis Portal Indiana Sign In
Odawa Hypixel
Franco Loja Net Worth
Arti kata petang-petang - Kamus Besar Bahasa Indonesia (KBBI) Online
Traftarım 24
Lewisburg Tn Jail Mugshots
Clea-Lacy Juhn: Schwerer Schicksalsschlag kurz nach Zwillingsgeburt
Cibo Tx International Kitchen Schertz Menu
How To Use Price Chopper Points At Quiktrip
Mexican cartel leader 'El Mayo' Zambada pleads not guilty to US charges
Power Outage Chehalis
Discord Id Grabber
Fast X Showtimes Near Regal Spartan
Fired Up | Rotten Tomatoes
Vci Classified Paducah
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 5545

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.