flymis/WebRoot/dojojs/src/math.js
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.math");
dojo.math.degToRad = function(/* float */x) {
// summary
// Converts degrees to radians.
return (x*Math.PI) / 180; // float
}
dojo.math.radToDeg = function(/* float */x) {
// summary
// Converts radians to degrees.
return (x*180) / Math.PI; // float
}
dojo.math.factorial = function(/* integer */n){
// summary
// Returns n!
if(n<1){ return 0; }
var retVal = 1;
for(var i=1;i<=n;i++){ retVal *= i; }
return retVal; // integer
}
dojo.math.permutations = function(/* integer */n, /* integer */k) {
// summary
// The number of ways of obtaining an ordered subset of k elements from a set of n elements
if(n==0 || k==0) return 1;
return (dojo.math.factorial(n) / dojo.math.factorial(n-k)); // float
}
dojo.math.combinations = function (/* integer */n, /* integer */r) {
// summary
// The number of ways of picking n unordered outcomes from r possibilities
if(n==0 || r==0) return 1;
return (dojo.math.factorial(n) / (dojo.math.factorial(n-r) * dojo.math.factorial(r))); // float
}
dojo.math.bernstein = function(/* float */t, /* float */n, /* float */i) {
// summary
// Calculates a weighted average based on the Bernstein theorem.
return (dojo.math.combinations(n,i) * Math.pow(t,i) * Math.pow(1-t,n-i)); // float
}
dojo.math.gaussianRandom = function(){
// summary
// Returns random numbers with a Gaussian distribution, with the mean set at 0 and the variance set at 1.
var k = 2;
do {
var i = 2 * Math.random() - 1;
var j = 2 * Math.random() - 1;
k = i * i + j * j;
后面还有 67 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。