This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dimsum:~/workspace/benchmarks $ ruby new_seed_bench.rb | |
| Random.new_seed | |
| 128612292610189266596556422956211714817 | |
| 6.2686e-05 | |
| PCGRandom.new_seed | |
| 12346887968840078306103323986432 | |
| 6.4614e-05 | |
| dimsum:~/workspace/benchmarks $ ruby new_seed_bench.rb | |
| Random.new_seed | |
| 218468435883139448544708591128323365688 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| require 'pcg_random' | |
| def m | |
| Random.new_seed | |
| end | |
| def n | |
| PCGRandom.new_seed | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name WhatsApp Text2Emoji | |
| // @namespace http://tampermonkey.net/ | |
| // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js | |
| // @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
| // @version 0.2 | |
| // @description Simple script that converts text smileys to emojis | |
| // @author Vaibhav Yenamandra | |
| // @match https://web.whatsapp.com/ | |
| // @grant none |