Skip to content

This small javascript library is containing statistic functions for regression analysis.

Notifications You must be signed in to change notification settings

STIFTMAN/Statistic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Statistic

This small javascript library is containing statistic functions for regression analysis.

Including file

Write <script language="javascript" type="text/javascript" src="statistic.js"></script> to your head.

Use

Example:
var myArray = [l,2,3,4];
var result = statistic.arithmetic_mean(myArray);
// result = 2.5

Functions

  • valid_input(array)
  • Checking, if elements of input array are rational numbers.
    Return value is true, if all elements are rational numbers or returning false if not.

  • arithmetic_mean(array)
  • Calculating the arithmetic mean of input array.
    Return value is arithmetic mean on success and NaN on failure.

  • median(array)
  • Calculating the median of input array.
    Returning median on success and NaN on failure.

  • standard_deviation(arr)
  • Calculating the standard deviation of input array.
    Returning standard deviation on sucess and NaN on failure.

  • pearson_correlation_coefficient(arrayX, arrayY)
  • Calcutaing pearson correlation coefficient of input array.
    Returning pearson correlation coefficient and NaN on failure.

  • correlation_coefficient(arrayX, arrayY)
  • Calcutaing correlation coefficient of input array.
    Returning correlation coefficient and NaN on failure.

  • regression_function(arrayX, arrayY)
  • Calcutaing regression function of input array.
    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)
  • Calcutaing x with given parameters from regression_function
    Returning x and NaN on failure.

  • predict_x(k,d,x)
  • Calcutaing y with given parameters from regression_function
    Returning y and NaN on failure.

    Notes

    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
    

    About

    This small javascript library is containing statistic functions for regression analysis.

    Topics

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published