(function() {
  
  var Random
  
  if( typeof module !== 'undefined' ) {
    module.exports = XOR
    if( typeof require === 'function' ) {
      var Random = require( '../' )
    }
  } else {
    Random = this.Random
    Random.XOR = XOR
  }
  
  function XOR( x, y, z, w ) {
    
    Random.call( this )
    
    this.x = x != null ? x : this.x
    this.y = y != null ? y : this.y
    this.z = z != null ? z : this.z
    this.w = w != null ? w : this.w
    
  }
  
  // Inherit from Random
  var $ = XOR.prototype =
    Object.create( Random.prototype )
  
  /**
   * Prototype's constructor
   * @type {Function}
   */
  $.constructor = XOR
  
  // Default seed parameters.
  // Provide a period of length 2^128 - 1
  $.x = 123456789
  $.y = 362436069
  $.z = 521288629
  $.w = 88675123
  
  /**
   * Get a random number in range [0,1]
   * @return {Number}
   */
  $.uniform = function() {
    
    var t = this.x ^ ( this.x << 11 )
    
    this.x = this.y
    this.y = this.z
    this.z = this.w
    
    this.w = this.w ^ (this.w >> 19) ^ (t ^ (t >> 8))
    
    return this.w / 0x7FFFFFFF
    
  }
  
})()