Please enable JavaScript to view this site.

Knowledge Base

Navigation: Scripting Language > Functions

randn

We've made some changes. Use 'Ctrl-F5' to clear your browser cache.
Scroll Prev Top Next More

Generates a normally distributed random number. In order to reset the generator seed use the command randreset.

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 

Syntax

Description

out = randn;

Generates a normally distributed random number with mean 0 and standard deviation 1.

out = randn(mean,stddev);

Generates a normally distributed random number with user defined mean value and standard deviation.

 

Example

This example shows how to create an histogram of a normal distribution.

n = 1000;

y = matrix(n);

mean_val = 1;

std_dev = 0.25;

 

for (i=1:n){

    y(i) = randn(mean_val, std_dev);

}

 

histc(y);

 

The histogram will look similar to the following one.

ref_scripts_example_randn_zoom63

 

See Also

Functions, randreset, lognrnd, randnmatrix

Copyright Lumerical Inc. | Privacy | Site Map