Skip to content

Instantly share code, notes, and snippets.

View gyaikhom's full-sized avatar

YAIKHOM gyaikhom

  • Scotland, United Kingdom
View GitHub Profile
@gyaikhom
gyaikhom / correlation_coefficient.js
Created December 18, 2014 12:02
Implements Pearson's product-moment correlation coefficient.
/* 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;
@gyaikhom
gyaikhom / linear_regression.js
Last active August 29, 2015 14:11
Implements linear regression
/* 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) {
@gyaikhom
gyaikhom / dijkstra_scc.c
Last active May 15, 2021 17:28
Implementation of Dijkstra's Algorithm for Strongly Connected Components.
/**
* 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
@gyaikhom
gyaikhom / quick_sort.c
Last active August 29, 2015 14:03
Implementation of Single-Pivot Quick Sorting.
/**
* 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) {
@gyaikhom
gyaikhom / selection_sort.c
Last active August 29, 2015 14:03
Implementation of Selection Sorting.
/**
* 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)
@gyaikhom
gyaikhom / insertion_sort.c
Last active August 29, 2015 14:03
Implementation of Insertion Sorting.
/**
* 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)
@gyaikhom
gyaikhom / tarjan_scc.c
Last active September 28, 2021 05:52
Implementation of Tarjan's Algorithm for Strongly Connected Components.
/**
* 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
@gyaikhom
gyaikhom / kosaraju_scc.c
Last active May 20, 2017 00:36
Implementation of Kosaraju's Algorithm for Strongly Connected Components.
/**
* 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