> Wiki ? API Reference ? Core ? Math
* 如發現翻譯不當或有其他問題可以通過以下方式聯系譯者:
* 郵箱:zhang_tianxu@sina.com
* QQ群:[D3數據可視化](http://jq.qq.com/?_wv=1027&k=ZGcqYF)205076374,[大數據可視化](http://jq.qq.com/?_wv=1027&k=S8wGMe)436442115
Pseudorandom Number Generation
你可以使用內置函數Math.random來生成統一的分布。例如,成介于0和99 (含)的隨機整數,可以調Math.floor(Math.random() * 100)。
# d3.random.normal([mean, [deviation]])
返回一個符合正態(高斯)分布normal (Gaussian) distribution的隨機數.
隨機變量的期望值是mean(默認為0.0), 標準差是deviation (默認為1.0)。
# d3.random.logNormal([mean, [deviation]])
返回一個滿足對數分布 log-normal distribution的隨機數.
隨機變量自然對數的期望值是mean(默認為0.0), 標準差是deviation (默認為1.0)。
# d3.random.bates(count)
返回一個符合貝茨分布Bates distribution的隨機數。count指定自變量的個數。
# d3.random.irwinHall(count)
返回一個符合歐文霍爾分布 Irwin–Hall distribution的隨機數。count指定自變量的個數。
2D Transforms
# d3.transform(string)
依照SVG的變換屬性transform attribute的定義,解析給定的2D仿射變換字符串.。分解這個字符串為一個由 平移、旋轉、X偏移和縮放組成的標準表示。此行為規范由CSS定義,參見:matrix decomposition for animation。
# transform.rotate
返回此變換的旋轉角θ,以度為單位。
# transform.translate
返回此變換的[ DX,DY ]平移,局部坐標(通常為像素)的兩元素數組。
# transform.skew
返回此變換的x的偏移φ ,單位為度。.
# transform.scale
返回變換的[kx, ky]縮放,一個兩元素數組。
# transform.toString
返回此轉換的字符串表示形式,其形式為 "translate(dx,dy)rotate(θ)skewX(φ)scale(kx,ky)"。
*guluT20140326