Skip to content

Instantly share code, notes, and snippets.

View v0dro's full-sized avatar

Sameer Deshmukh v0dro

View GitHub Profile
@v0dro
v0dro / R output
Last active August 29, 2015 14:06
Problem in statsample-glm
# Note : The GLM results from R match those from statsample but do not match those of statsample-glm. Here is my R code.
> csv = read.csv("/home/sameer/github_repos/statsample/test/fixtures/test_binomial.csv")
> attach(csv)
> glm(y ~ +a+b+c, family = binomial)
# => Output
Call: glm(formula = y ~ +a + b + c, family = binomial)
@v0dro
v0dro / NMatrix C function writing guide
Last active August 29, 2015 14:10
Writing a C function for NMatrix
You first have a function say `__solve__` being called from ruby code.
You then declare the equivalent C function that will be called from the C code that will be executed when `__solve__` is called.
These declarations (which look like `rb_define_function_blah_blah`) are kept inside a function called `void Init_nmatrix()` in the file `ruby_nmatrix.c`.
Say the C function is called `nm_solve`, then the declaration looks like `rb_define_private_method(cNMatrix, "__solve__", (METHOD)nm_solve, 4);`.
This `nm_solve` function should be declared in the file `ruby_nmatrix.c`.
Then you have a function called `nm_solve` in math.cpp whose sole function is to take shit (arguments) from `__solve__`, make sense of them (if any) and then call a C function called `nm_math_solve` whose sole job is to do the `ttable` stuff, and with those helpful macros, generate a C++ function call of the appropriate data type.
@v0dro
v0dro / commits
Last active August 29, 2015 14:11
OSS Contributions
NMatrix: an efficient storage and linear algebra library for Ruby
HB input and fortran format parser:
Made a new class for parsing matrices stored in the Harwell Boeing file format
and loading the data as an nmatrix. Also wrote a separate class for parsing FORTRAN
number formats, which tells the data type and storage of numbers in a text file.
Link:
https://github.com/SciRuby/nmatrix/commit/b4d3c25aa8d32f9bd20b6c0ac4b10b3f6933f2c4
LAPACK free matrix inverse, #round, Rational division fix:
@v0dro
v0dro / gsl-nmatrix with statsample failure
Created May 7, 2015 10:46
statsample build failure with gsl-nmatrix
1) Error:
StatsampleFactorTestCase#test_covariance_matrix:
NoMethodError: private method `[]=' called for #<Matrix:0xa1667a0>
/home/sameer/gitrepos/statsample/lib/statsample/factor/pca.rb:156:in `block (2 levels) in component_matrix_covariance'
/home/sameer/gitrepos/statsample/lib/statsample/factor/pca.rb:155:in `times'
/home/sameer/gitrepos/statsample/lib/statsample/factor/pca.rb:155:in `block in component_matrix_covariance'
/home/sameer/gitrepos/statsample/lib/statsample/factor/pca.rb:154:in `times'
/home/sameer/gitrepos/statsample/lib/statsample/factor/pca.rb:154:in `component_matrix_covariance'
/home/sameer/gitrepos/statsample/lib/statsample/factor/pca.rb:145:in `component_matrix'
/home/sameer/gitrepos/statsample/test/test_factor.rb:25:in `test_covariance_matrix'
@v0dro
v0dro / gist:5c886a2a6dbf44fcffc7
Created May 7, 2015 11:12
statsample without rb-gsl
Finished in 48.920916s, 8.2378 runs/s, 25.8376 assertions/s.
1) Failure:
StatsampleReliabilityIccTestCase#test_: Statsample::Reliability::ICC with Shrout & Fleiss denominations, should icc(2,1) confidence interval should be correct. [/home/sameer/gitrepos/statsample/test/test_reliability_icc.rb:81]:
Expected |0.019 - -0.02227501611508347| (0.04127501611508347) to be <= 0.001.
2) Failure:
StatsampleReliabilityIccTestCase#test_: Statsample::Reliability::ICC McGraw and Wong ICC Type icc_a_k should bounds be equal. [/home/sameer/gitrepos/statsample/test/test_reliability_icc.rb:186]:
Expected |0.98156527598367 - 0.9759274278050467| (0.005637848178623339) to be <= 0.001.
require 'daru'
require 'gnuplotrb'
require 'statsample-timeseries'
index = Daru::DateTimeIndex.date_range :start => '2012', :periods => 500
iteration_count = 500
actual_values = Daru::Vector.new(iteration_count.times.map { |j| -0.37727 + j * j * 0.00001}, index: index)
noisy_data = Daru::Vector.new(actual_values.map { |actual_val| rand * 0.6 - 0.3 + actual_val }, index: index)
GnuplotRB::Plot.new(
a=Daru::DataFrame.from_csv('spec/fixtures/sales-funnel.csv',headers: true)
=>
#<Daru::DataFrame:84880950 @name = 42706995-535d-4181-9a13-9ba2f4f65b3f @size = 17>
account manager name price product quantity rep status
0 714466 Debra Henl Trantow-Ba 30000 CPU 1 Craig Book presented
1 714466 Debra Henl Trantow-Ba 10000 Software 1 Craig Book presented
2 714466 Debra Henl Trantow-Ba 5000 Maintenanc 2 Craig Book pending
3 737550 Debra Henl Fritsch, R 35000 CPU 1 Craig Book declined
4 146832 Debra Henl Kiehn-Spin 65000 CPU 2 Daniel Hil won
5 218895 Debra Henl Kulas Inc 40000 CPU 2 Daniel Hil pending
@v0dro
v0dro / Compiling NMatrix
Last active December 18, 2015 09:49
Compiling nmatrix on your local machine
'apt-get' install atlas and its dev files (I installed libatlas3-base, libatlas-base-dev, libatlas3gf-base, and libatlas-dev iirc. Not sure if all of these are needed; I just grabbed everything that looked relevant.).
Followed by: export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/atlas before compiling nmatrix from source. (If I leave out the export, I have the same error shown in the gist linked in the OP.)
So at least for me, it was just a matter of ubuntu putting the headers in a different location.
@v0dro
v0dro / final_report.md
Last active March 4, 2016 10:32
RAG 2015 final report
@v0dro
v0dro / c_test_for_ruby_gems.md
Created March 5, 2016 06:25
C test harness for gems

Planning