Reputation: 867
I'm building a web app that needs to calculate statistics on a data set. I need to calculate percentiles, averages, modes, and other statistical functions on arrays.
Normally in Python, I would just use scipy, numpy, or nltk which has a huge library of stat array functions. Are there any ruby gems or libraries I can utilize to do this?
In the case that there aren't any existing libraries, is there an easy way to do my data processing in Python while keeping my app in Ruby/Rails?
Upvotes: 9
Views: 6560
Reputation: 131
I have implemented a new gem "MDArray" that does statistics in JRuby. This might be actually quite good for a web app, as JRuby is basically Java. MDArray follows NArray and Numpy philosophy and altough at this point it is probably slower than both, it should be faster than a pure Ruby alternative.
Check it out and if you need any help I´ll be glad to try and help.
Upvotes: 0
Reputation: 80065
For numbercrunching Narray is the standard recommendation. It's statistical methods are Summation, Cumulative Summation, Product (Multiply elements), Cumulative Produce, Mean, Standard deviation, Root mean square, Root mean square deviation, Minimum, Maximum, and median.
Being specialised for numbers, it is claimed to be upto 50 times faster and more memory efficient tham Array.
Upvotes: 0
Reputation: 4002
You can use NMatrix, which is a numerical library similar to NumPy in constant development. (disclaimer: I'm from the SciRuby/NMatrix team)
Upvotes: 0
Reputation: 958
If you're calculating statistics on ActiveRecord models then you'll probably want to check out the statistics gem.
I've also bookmarked statisticus which offers GNU-R integration and SIRB for use in the console.
There are myriad ways to run Python under a Rails app but it's probably easier to find the methods you need in a Ruby library.
Upvotes: 0
Reputation: 3861
If you really need a full statistics library, take a look at statsample. Otherwise you may find descriptive_statistics to be a nice, lightweight alternative.
Upvotes: 7