<commit_before>var AbstractEngine = require('./AbstractEngine')
var inherits = require('util').inherits
var Random = require('random-js')
var debug = require('./debug')('RandomEngine')

module.exports = RandomEngine

/**
 *	@param {Array} pool - objects to pick from
 *	@param {int}	seed - an optional seed that will be used to recreate a random sequence of selections
 */
function RandomEngine(pool, seed) {
	if (!(this instanceof RandomEngine)) return new RandomEngine(pool, seed)
	
	AbstractEngine.call(this, pool)

	this._maxPick = pool.length - 1

	if (typeof (seed) === 'number') {
		debug('using Mersenne Twister engine with seed %d', seed)
		this._r = new Random( Random.engines.mt19937().seed(seed))
	} else {
		debug('using native math engine')
		this._r = new Random( Random.engines.nativeMath)
	}
}

inherits(RandomEngine, AbstractEngine)

RandomEngine.prototype.pick = function() {
	var index = this._lastPick = this._r.integer(0, this._maxPick)
	return this._pool[index]
}<commit_msg>do not use native math for random at all<commit_after>var AbstractEngine = require('./AbstractEngine')
var inherits = require('util').inherits
var Random = require('random-js')
var debug = require('./debug')('RandomEngine')

module.exports = RandomEngine

/**
 *	@param {Array} pool - objects to pick from
 *	@param {int}	seed - an optional seed that will be used to recreate a random sequence of selections
 */
function RandomEngine(pool, seed) {
	if (!(this instanceof RandomEngine)) return new RandomEngine(pool, seed)
	
	AbstractEngine.call(this, pool)

	this._maxPick = pool.length - 1

	if (typeof (seed) === 'number') {
		debug('using Mersenne Twister engine with seed %d', seed)
		this._r = new Random( Random.engines.mt19937().seed(seed))
	} else {
		debug('using Mersenne Twister engine with autoSeed')
		this._r = new Random( Random.engines.mt19937().autoSeed())
	}
}

inherits(RandomEngine, AbstractEngine)

RandomEngine.prototype.pick = function() {
	var index = this._lastPick = this._r.integer(0, this._maxPick)
	return this._pool[index]
}
{'fraction_non_alphanumeric': 0.13206627680311891, 'fraction_numerical': 0.009259259259259259, 'mean_word_length': 4.76685393258427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7277476', 'n_tokens_mistral': 656, 'n_tokens_neox': 617, 'n_words': 190}