Skip to content

Instantly share code, notes, and snippets.

@KrisKusano
KrisKusano / jermakian_2012_table2.csv
Created September 9, 2020 18:05
Table 2 from Jermakian 2012 paper "Crash avoidance potential of four large truck technologies"
Crash type All crashes Nonfatal injury crashes (A or B) Fatal crashes Group
Lane-changing/merging/turning 97,000 6000 444 All trucks
Angle (without lane-changing) 35,000 6000 783 All trucks
Front-to-rear (without lane-changing) 84,000 9000 681 All trucks
Single-vehicle (without lane-changing) 102,000 8000 850 All trucks
Front-to-front head-on (without lane-changing) 3000 1000 492 All trucks
Front-to-front other (without lane-changing) 1000 <1000 126 All trucks
Sideswipe same direction (without lane-changing) 48,000 3000 203 All trucks
Sideswipe opposite direction (without lane-changing) 13,000 3000 522 All trucks
Other (e.g., rear-to-rear, end-swipe, unknown) <1000 <1000 48 All trucks
@KrisKusano
KrisKusano / quote_delim_table.m
Last active August 29, 2015 14:05
wrap all strings in table that contain a delimiter with a quote character
function tableout = quote_delim_table(tablein, delimiter, varargin)
%% wrap all strings in table that contain a delimiter with a quote character
% SYNTAX
% tableout = quote_delim_table(tablein, delimiter)
% tableout = quote_delim_table(tablein, delimiter, quotechar)
%
% DESCRIPTION
% tableout = quote_delim_table(tablein, delimiter) all character columns in
% tablein, and wraps strings containing delimiter with a double quote ('"')
%
@KrisKusano
KrisKusano / AUC.m
Created June 24, 2014 16:26
compute AUC for Kaggle Competition results
function auc = AUC(pred, act)
%% compute the AUC for Kaggle competitions
% auc = AUC(pred, act) returns the AUC value on [0, 1]. pred is the predicted
% class membership, {0, 1}, and act is the actual class membership, also {0, 1}
%
% Sources:
% http://link.springer.com/article/10.1023%2FA%3A1010920819831
% http://www.kaggle.com/c/SemiSupervisedFeatureLearning/forums/t/919/auc-implementation/6130
%
% Kristofer D. Kusano - 6/24/14
function table = tabulate_wgt(x, frequency)
%TABULATE Frequency table.
% TABLE = TABULATE(X, FREQUENCY) takes a vector X and returns a matrix, TABLE.
% The first column of TABLE contains the unique values of X. The
% second is the number of instances of each value. The last column
% contains the percentage of each value. If the elements of X are
% non-negative integers, then the output includes 0 counts for any
% integers that are between 1 and max(X) but do not appear in X. The counts
% (second column) and percentage (third column) use frequency.
%
@KrisKusano
KrisKusano / chutes_and_ladders.m
Created May 4, 2014 18:58
Play a game of "Chutes and Ladders" in MATLAB
function p = chutes_and_ladders()
%% Chutes and ladder game
% Plays chutes and ladders game on a 10x10 board. All players start off the
% board (position 0). Players take turns rolling a 6-sided dice and moving up
% the board. There are 10 chutes and 9 ladders that can skip players ahead.
% Rolling a 6 allows the player to roll again. Rolling 3 consecutive 6's,
% however, sends the player back to space 1. The player is stuck at space 1
% until they roll a 6 again.
%
% chutes_and_ladders.m