This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2014 Gagarine Yaikhom MIT License | |
* | |
* Implements Pearson's product-moment correlation coefficient. | |
* (see http://stattrek.com/statistics/correlation.aspx?tutorial=ap) | |
*/ | |
function correlation_coefficient(datapoints) { | |
var sum_x, sum_y, mean_x, mean_y, | |
dx, dy, sum_dx_dy, sum_dx_2, sum_dy_2, | |
n, i, d, result; | |
result = undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2014 Gagarine Yaikhom (MIT License) | |
* | |
* Implements linear regression. | |
* (see https://www.khanacademy.org for derivation) | |
*/ | |
function linear_regression(datapoints) { | |
var sum_x, sum_y, sum_x_2, sum_xy, mean_x, mean_y, | |
m, b, n, i, d, result, se_mean, se_line; | |
result = undefined; | |
if (datapoints instanceof Array) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2014 Gagarine Yaikhom (MIT License) | |
* | |
* Implementation of Dijkstra's Algorithm for Strongly Connected Components. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define MAX_DEGREE 5 | |
#define MAX_NUM_VERTICES 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2014 Gagarine Yaikhom (MIT License) | |
* | |
* Implementation of Single-Pivot Quick Sorting. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
void print_array(const int *a, int size) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2014 Gagarine Yaikhom (MIT License) | |
* | |
* Implementation of Selection Sorting. | |
*/ | |
#include <stdio.h> | |
void print_array(const int *a, int size) { | |
int i; | |
for (i = 0; i < size; ++i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2014 Gagarine Yaikhom (MIT License) | |
* | |
* Implementation of Insertion Sorting. | |
*/ | |
#include <stdio.h> | |
void print_array(const int *a, int size) { | |
int i; | |
for (i = 0; i < size; ++i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2014 Gagarine Yaikhom (MIT License) | |
* | |
* Implementation of Tarjan's Algorithm for Strongly Connected Components. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define MAX_DEGREE 5 | |
#define MAX_NUM_VERTICES 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2014 Gagarine Yaikhom (MIT License) | |
* | |
* Implementation of Kosaraju's Algorithm for Strongly Connected Components. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define MAX_DEGREE 5 | |
#define MAX_NUM_VERTICES 20 |