Skip to content

Instantly share code, notes, and snippets.

View ryanseys's full-sized avatar
🌴

Ryan Seys ryanseys

🌴
View GitHub Profile
@ryanseys
ryanseys / ellipse-simulation.js
Created February 10, 2015 04:31
Ellipse Simulation
function Ellipse(width, height, cx, cy) {
this.height = height;
this.width = width;
this.x = cx;
this.y = cy;
}
Ellipse.prototype.contains = function(x, y) {
var term1 = Math.pow(x - this.x, 2)/Math.pow(this.width/2, 2);
var term2 = Math.pow(y - this.y, 2)/Math.pow(this.height/2, 2);
var vq = function () {
var heart = ' '+
'\n _____ _____ '+
'\n ,ad8PPPP88b, ,d88PPPP8ba, '+
'\n d8P" "Y8b, ,d8P" "Y8b '+
'\n dP´ "8a8" `Yd '+
'\n 8( " )8 '+
'\n I8 8I '+
'\n Yb, BE MY ,dP '+

Keybase proof

I hereby claim:

  • I am ryanseys on github.
  • I am ryanseys (https://keybase.io/ryanseys) on keybase.
  • I have a public key whose fingerprint is 67C5 6072 AC55 ACC3 FF90 FE02 E6E9 472D B65E 12D2

To claim this, I am signing this object:

NAME LAB3A
;*****************************************************************************
; B E G I N N I N G O F P R O G R A M
;*****************************************************************************
;-----------------------------------------------------------------------------
; E Q U A T E S
;-----------------------------------------------------------------------------
NAME LAB3B
;*****************************************************************************
; B E G I N N I N G O F P R O G R A M
;*****************************************************************************
;-----------------------------------------------------------------------------
; E Q U A T E S
;-----------------------------------------------------------------------------
@ryanseys
ryanseys / LAB3C.asm
Last active August 29, 2015 14:16
Lab 3C
NAME LAB3B
;*****************************************************************************
; B E G I N N I N G O F P R O G R A M
;*****************************************************************************
;-----------------------------------------------------------------------------
; E Q U A T E S
;-----------------------------------------------------------------------------
@ryanseys
ryanseys / reverse-decimal.js
Created March 15, 2015 17:41
Reverse the numbers after decimal in list of numbers
function reverseDecimal(num) {
var arr = num.toString().split('.');
arr[1] = arr[1].split('').reverse().join('');
return parseFloat(arr.join('.'));
}
var numbers = [0.24, 0.35, 0.76];
console.log(numbers.map(reverseDecimal));
@ryanseys
ryanseys / poisson-packet.js
Created March 17, 2015 16:55
First N Packet Poisson Arrival Times
function firstNPacketPoissonArrivals(n, rate, t) {
n--;
t = t || 0;
var u, x;
var lambda = rate;
u = Math.random(); // random value between [0, 1]
x = (-1/lambda)*Math.log(1-u);
t = t + x;
console.log('Arrival of packet at time: ' + t);
if (n > 0) {
// Acceptance rejection technique
function AcceptReject() {}
AcceptReject.prototype.inverseG = function(x) {
return -1 * Math.log((1 - x) / 2.85);
};
AcceptReject.prototype.f = function(x) {
return 20 * x * Math.pow(1 - x, 3);
};
function getUniformRandomNumber() {
return Math.random();
}
// Rate is the rate parameter of the exponential
// distribution. Typically denoted by lambda.
function getExponentialRandomNumber(rate) {
return Math.log(1 - Math.random()) / (−rate);
}