<script language="javascript" type="text/javascript" src="statistic.js"></script>
to your head.
Example:
var myArray = [l,2,3,4];
var result = statistic.arithmetic_mean(myArray);
// result = 2.5
valid_input(array)
Return value is true, if all elements are rational numbers or returning false if not.
arithmetic_mean(array)
Return value is arithmetic mean on success and NaN on failure.
median(array)
Returning median on success and NaN on failure.
standard_deviation(arr)
Returning standard deviation on sucess and NaN on failure.
pearson_correlation_coefficient(arrayX, arrayY)
Returning pearson correlation coefficient and NaN on failure.
correlation_coefficient(arrayX, arrayY)
Returning correlation coefficient and NaN on failure.
regression_function(arrayX, arrayY)
Returning array with arr[0] = k and arr[1] = d and NaN on failure. Using function Y = K*X + D .
predict_y(k,d,y)
regression_function
Returning x and NaN on failure.
predict_x(k,d,x)
regression_function
Returning y and NaN on failure.
Make sure that, if you are using
pearson_correlation_coefficient
, correlation_coefficient
or regression_function
, your input arrays are matching each other.
For example:
Your data
X # Y ######### 1.0 # 2.0 1.3 # 2.6 1.7 # 2.4 2.1 # 2.7 2.0 # 2.8 2.5 # 3.0
Your array have to be like this:
var arr1 = [ 1.0, 1.3, 1.7, 2.1, 2.0, 2.5 ] -> All X values var arr2 = [ 2.0, 2.6, 2.4, 2.7, 2.8, 3.0 ] -> All Y values
Matching
arr1[0] -> arr2[0] ... arr1[i] -> arr2[i] == X -> Y