A simple app to compare performance of the MATLAB® random number generators on your machine.
Random number generator (RNG) performance can vary a lot for different CPU or GPU hardware. It also depends on the choice of uniformly or normally distributed sample generation. Use this application to view side-by-side comparisons of RNG performance in MATLAB, and optionally the GPU-enabled RNGs.
To install the app from within MATLAB:
- Open the Add-Ons panel by clicking the Add-Ons icon on the left sidebar of the desktop.
- Search for "CompareRNG" in the search box at the top of the Add-Ons panel.
- Select the app from the list and click the Install button.
For alternative installation methods, see Get and Manage Add-Ons.
To use this app, you need:
- MATLAB release R2025a or newer.
- (Optional) Parallel Computing Toolbox™ and a supported NVIDIA® GPU. These are required to measure the performance of GPU random number generators. For more information about supported GPU devices, see GPU Computing Requirements.
To open the app, go to the Apps tab and expand the apps gallery by clicking the down arrow on the far right, then click on the app icon in the My Apps section.
To start measuring random number generator performance, select a CPU or GPU generator by ticking the box next to its name. The app then computes the results for that generator. You can also select or deselect all CPU or GPU generators using the parent entries CPU or GPU.
By default, the app measures the performance of generating large arrays of
random numbers using the rand
function.
To instead measure the performance of normally-distributed random number
generators, you can choose to use the randn
function.
The plotted data can be exported to the MATLAB workspace as a table for further analysis using the Export to Workspace button.
If MATLAB cannot find your GPU, use the validateGPU
function to help diagnose the issue.
The license is available in the license.txt file in this GitHub repository.
Copyright 2025 The MathWorks, Inc.