0
0

More than 3 years have passed since last update.

P5.js 日本語リファレンス(randomGaussian)

Last updated at Posted at 2020-05-24

このページでは「P5.js 日本語リファレンス」 の randomGaussian関数を説明します。

randomGaussian()

説明文

ガウスまたは正規分布に適合する乱数を返します。理論的には randomGaussian() が返す可能性のある最小値または最大値はありません。むしろ、平均から離れた値が返される可能性は非常に低いです。平均値に近い数値が返される可能性が高くなります。

引数なし、あるいは1または2つの引数を取ります。
引数がない場合は, 平均0と標準偏差1を返します。
1つの引数の場合、その引数は平均です(標準偏差は1)。
2つの引数がある場合、最初は平均、2番目は標準偏差です。

構文

randomGaussian(mean, sd)

パラメタ

  • mean

    Number:平均

  • SD

    Number:標準偏差

戻り値

Number:乱数

// x = 100 を中心(平均)に乱数を求めます。
function setup(){
  createCanvas(200, 200);
  background(255);
}

function draw(){
  for (let y = 0; y < 200; y++) {
    let x = randomGaussian(100, 20);
    point(x, y)
  }
}

実行結果

著作権

p5.js was created by Lauren McCarthy and is developed by a community of collaborators, with support from the Processing Foundation and NYU ITP. Identity and graphic design by Jerel Johnson.

ライセンス

Creative Commons(CC BY-NC-SA 4.0) に従います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0