起首來看matlab的幫忙文檔,
第一行Control random number generation(節制隨機數的生當作,不知道這么翻譯對不合錯誤,接著看)
Syntax(句法的意思),介紹了幾種常用的挪用體例
rng(seed) seeds the random number generator using the nonnegative integer seed so that rand, randi, and randn produce a predictable sequence of numbers.(rng(種子)種子利用非負整數種子種子,使rand、randi和randn發生一個可展望的數字序列。)
rng('shuffle') seeds the random number generator based on the current time. Thus, rand, randi, and randn produce a different sequence of numbers after each time you call rng.(rng('shuffle')種子基于當前時候生當作隨機數生當作器。是以,蘭德、randi和蘭德在每次挪用rng之后城市發生分歧的數字序列。)
此處可以理解,因為電腦的隨機數并不是像擲骰子一樣和實際中一樣隨機,接著看
這一段就不翻譯了,這里就可以看出電腦的隨機數是操縱了一些算法生當作的,這里列出了七種算法
后面還有一部門也不翻譯了,本身看很輕易理解的
END幫忙里有例子,我鄙人邊又本身嘗試了一下
輸入兩次rand(2),成果紛歧樣
輸入rand(2)前加上rng(10,'twister'),此次就一樣了,這里就應該理解的很清晰了
END0 篇文章
如果覺得我的文章對您有用,請隨意打賞。你的支持將鼓勵我繼續創作!