Skip to content

Instantly share code, notes, and snippets.

View envp's full-sized avatar

Vaibhav Yenamandra envp

View GitHub Profile
@envp
envp / issue_description_c9
Created March 10, 2016 16:37
Because c9.io doesnt like if you have 2+ links in a post.
1. When I load c9.io for the first time, no styles are loaded from cdn.c9.io and I get a screen [like this](http://puu.sh/nBEwg/b9cf73fe0e.png).
2. After going to status.c9.io, which needs me to fill out a [captcha](http://puu.sh/nBEGI/92762b043c.jpg). I am able to see my dashboard with proper styling, but is still missing some resources all of which are from cdn.c9.io.
3. [See screenshot of above](http://puu.sh/nBEN9/3b9a868896.png) Note the missing glyphicons in this picture. [And a dropbox link to the console logs](https://www.dropbox.com/s/stn8rl62ndz50v1/c9.io-1457627113298.log?dl=0)
4. Now when I click on "Open" to open my workspace. It gets [stuck loading](http://puu.sh/nBF5n/427dde3458.png). Here's the [dropbox log for that](https://www.dropbox.com/s/jcujwnsvb4uvc9a/ide.c9.io-1457627242366_stuck_Loading.log?dl=0)
@envp
envp / spec_template.rb
Last active February 18, 2016 13:29
Generic template for distribution test cases
describe Statistical::Distribution::DistNameGoesHere do
describe '.new' do
context 'when called with no arguments'
context 'when upper and lower bounds are specified'
end
describe '#pdf' do
context 'when called with x < lower'
context 'when called with x > upper'
context 'when called with x in [lower, upper]'
@envp
envp / meta.rb
Last active February 18, 2016 09:19
# require all the rngs defined in lib/statistical/rng
require 'statistical/rng/uniform'
module Statistical
module Rng
# :nodoc:
# Dynamically add constant RNG_TYPES when called
def self.const_missing(cname)
if cname == 'RNG_TYPES'.to_sym
@envp
envp / goto_evil.rb
Last active February 1, 2016 18:20
state = 1
counter = 0
# Customary: "Here be evil"
# For a live version, see: https://repl.it/BiiG/1
loop do
puts [state, counter].inspect
case state
when 1
@envp
envp / ruby.rb
Last active January 29, 2016 12:14
lib/distribution/binomial/ruby.rb
module Distribution
module Binomial
module Ruby_
class << self
# Returns a `Proc`object that yields a random integer `k` <= `n`
# which is binomially distributed with mean np and variance np(1-p)
# This method uses Luc Devroye's "Rejection Method" from page 533
# of his text: "Non-Uniform Random Variate Generation."
#
# @param n [Fixnum] the total number of trials
@envp
envp / BtrdAlgorithm.rb
Last active January 26, 2016 18:18
Implementation of BTRD binomial random varirate generation algo from http://epub.wu.ac.at/1242/1/document.pdf . THIS IS EXPLOSIVE CODE IN PUBLIC DOMAIN. USE WITH CAUTION.
# When the mean is still small, but the probability of success
# is not miniscule. Covers n > 20
# Taken from "The Generation of Binomial Random Variates"
# Wolfgang Hormann (http://epub.wu.ac.at/1242/1/document.pdf)
# This is algorithm BTRD from the text
# This is a precalculated table for correction terms in
# stirling's approximation to log(k!) each index corresponds
# to a seperate value of k
fc_table = [0.08106146679532726, 0.04134069595540929,
@envp
envp / ruby.rb
Last active January 26, 2016 04:03
lib/distribution/binomial/ruby.rb
# Returns the inverse-CDF or the quantile given the probability `prob`,
# the total number of trials `n` and the number of successes `k`
# Note: This is a binary search under the hood and is a candidate for
# updates once more stable techniques are found.
# This still needs to be optimized and benchmarked against
# the vanilla quantile
#
# @paran qn [Float] the cumulative function value to be inverted
# @param n [Fixnum, Bignum] total number of trials
# @param prob [Float] probabilty of success in a single independant trial
@envp
envp / rb_rand_entropy.rb
Last active January 25, 2016 06:05
Finding the entropy for Ruby's random method as a measure of it's randomness
def rb_rand_entropy(num_trials)
a = Array.new(num_trials) {rand(100)}
p = []
0.upto(99) do |i|
p[i] = a.count(i) / num_trials.to_f
end
return p.map {|c| -c * Math.log(c)}.reduce(:+)
end
@envp
envp / goodnes_of_fit.rb
Last active January 20, 2016 10:44
Untested stuff. Does chi-squared tests. Has a lot of ad-hack stuff. This implements a pearson's chi squared test. Others to follow soon
module GoodnessOfFit
# All goodness of fit helpers go here
## Pearson's chi squared test for goodness of fit
# == References
# * http://stattrek.com/chi-square-test/goodness-of-fit.aspx?Tutorial=AP
# * https://en.wikipedia.org/wiki/Degrees_of_freedom_(statistics)#Residuals
#
# The null hypothesis is always that the +candidate+ does belong to
# the +target+ distribution.
Pending: (Failures listed here are expected and do not affect your suite's status)
1) Distribution::Uniform singleton it should behave like uniform engine .rng should generate sequences with the right mean & variance
# This method is very innacurrate due to the low convergence rate
# ./spec/uniform_spec.rb:8
2) Distribution::Uniform Distribution::Uniform::Ruby_ it should behave like uniform engine .rng should generate sequences with the right mean & variance
# This method is very innacurrate due to the low convergence rate
# ./spec/uniform_spec.rb:8