<commit_before>/**
 * jStat - JavaScript Statistical Library
 * Copyright (c) 2011
 * This document is licensed as free software under the terms of the
 * MIT License: http://www.opensource.org/licenses/mit-license.php */
(function( Math, _this, undefined ) {
	var slice = Array.prototype.slice,
		toString = Object.prototype.toString,

		// ascending/descending functions for sort
		ascNum = function( a, b ) { return a - b; },
		descNum = function( a, b ) { return b - a; },

		// test if array
		isArray = function( arg ) {
			return toString.call( arg ) === "[object Array]";
		},

		// simple method to run functions in setTimeout
		callLater = function( func, context, values ) {
			setTimeout( function() {
				func.apply( context, values );
			}, 10 );
		};

	function jstat() {
		return new jstat.fn.init( slice.call( arguments ) );
	};

	jstat.fn = jstat.prototype = {
		constructor : jstat,
		init : function( args ) {
			// if first argument is an array, must be vector or matrix
			if ( isArray( args[0] )) {
				for ( var i = 0; i < args.length; i++ ) {
					this.push( args[i] );
				};
			// if first argument is number, assume creation of sequence
			} else if ( !isNaN( args[0] )) {
				this.push( jstat.seq.apply( this, args ));
			};
			return this;
		},
		length : 0,
		toArray : function() {
			return slice.call( this, 0 );
		},
		push : Array.prototype.push,
		sort : [].sort,
		splice : [].splice
	};
	jstat.fn.init.prototype = jstat.fn;

	// TODO: there's got to be an easy way to combine these two
	// create method for easy extension
	jstat.extend = function( obj ) {
		for ( var i in obj ) {
			jstat[i] = obj[i];
		};
		return this;
	};
	jstat.fn.extend = function( obj ) {
		for ( var i in obj ) {
			jstat.fn[i] = obj[i];
		};
		return this;
	};

	// cast applicable array operations to the prototype
	(function( funcs ) {
		funcs = funcs.split( ' ' );
		for ( var i = 0; i < funcs.length; i++ ) (function( passfunc ) {
			jstat.fn[ funcs[i] ] = function( func ) {
				for ( var i = 0; i < this.length; i++ ) {
					callLater( func, jstat( this[i] ), [ jstat[ passfunc ]( this[i] )]);
				};
				return this;
			};
		})( funcs[i] );
	})( 'sum min max mean median mode range variance stdev meandev meddev quartiles' );	

	// extend jstat
	jstat.fn.extend({
		seq : function( start, count ) {
			this.push( jstat.seq( start, count ));
			return this;
		}
	});

	// TODO: allow for sequence creation based on a function
	// generate sequence
	jstat.seq = function( start, count ) {
		var arr = [], i = 0;
		if ( count > 0 ) {
			for ( ; i < count; i++ ) arr.push( start++ );
		} else {
			for ( ; i > count; i-- ) arr.push( start-- );
		};
		return arr;
	};
	// sum of an array
	jstat.sum = function( arr ) {<commit_msg>can now pass function to sequence<commit_after>/**
 * jStat - JavaScript Statistical Library
 * Copyright (c) 2011
 * This document is licensed as free software under the terms of the
 * MIT License: http://www.opensource.org/licenses/mit-license.php */
(function( Math, _this, undefined ) {
	var slice = Array.prototype.slice,
		toString = Object.prototype.toString,

		// ascending/descending functions for sort
		ascNum = function( a, b ) { return a - b; },
		descNum = function( a, b ) { return b - a; },

		// test if array
		isArray = function( arg ) {
			return toString.call( arg ) === "[object Array]";
		},

		// test if function
		isFunction = function( arg ) {
			return toString.call( arg ) === "[object Function]";
		},

		// simple method to run functions in setTimeout
		callLater = function( func, context, values ) {
			setTimeout( function() {
				func.apply( context, values );
			}, 10 );
		};

	function jstat() {
		return new jstat.fn.init( slice.call( arguments ) );
	};

	jstat.fn = jstat.prototype = {
		constructor : jstat,
		init : function( args ) {
			// if first argument is an array, must be vector or matrix
			if ( isArray( args[0] )) {
				for ( var i = 0; i < args.length; i++ ) {
					this.push( args[i] );
				};
			// if first argument is number, assume creation of sequence
			} else if ( !isNaN( args[0] )) {
				this.push( jstat.seq.apply( this, args ));
			};
			return this;
		},
		length : 0,
		toArray : function() {
			return slice.call( this, 0 );
		},
		push : Array.prototype.push,
		sort : [].sort,
		splice : [].splice
	};
	jstat.fn.init.prototype = jstat.fn;

	// TODO: there's got to be an easy way to combine these two
	// create method for easy extension
	jstat.extend = function( obj ) {
		for ( var i in obj ) {
			jstat[i] = obj[i];
		};
		return this;
	};
	jstat.fn.extend = function( obj ) {
		for ( var i in obj ) {
			jstat.fn[i] = obj[i];
		};
		return this;
	};

	// cast applicable array operations to the prototype
	(function( funcs ) {
		funcs = funcs.split( ' ' );
		for ( var i = 0; i < funcs.length; i++ ) (function( passfunc ) {
			jstat.fn[ funcs[i] ] = function( func ) {
				for ( var i = 0; i < this.length; i++ ) {
					callLater( func, jstat( this[i] ), [ jstat[ passfunc ]( this[i] )]);
				};
				return this;
			};
		})( funcs[i] );
	})( 'sum min max mean median mode range variance stdev meandev meddev quartiles' );	

	// extend jstat
	jstat.fn.extend({
		seq : function( start, count, func ) {
			this.push( jstat.seq( start, count, func ));
			return this;
		}
	});

	// generate sequence
	jstat.seq = function( start, count, func ) {
		var arr = [], i = 0;
		if ( count > 0 ) {
			for ( ; i < count; i++ ) arr.push( func ? func.call( this, start++ ) : start++ );
		} else {
			for ( ; i > count; i-- ) arr.push( start-- );
		};
		return arr;
	};
	// sum of an array
	jstat.sum = function( arr ) {
{'fraction_non_alphanumeric': 0.1561001598295152, 'fraction_numerical': 0.005327650506126798, 'mean_word_length': 2.659519168291098, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3769133', 'n_tokens_mistral': 2187, 'n_tokens_neox': 1923, 'n_words': 618}