This is also a question that relates very much to Python as a statistics workbench and excel as a statistics workbench. I know there is a huge discussion about Ruby versus Python but this is not the point on this question. I thought that Ruby being faster than Python and having a very natural syntax could benefit me to understand statistics and could be also a good alternative to R (which is also of my interest and was cited at my other question on R here). For instance, on one of the Google Tech lectures I've seen (cited on the linked question here, the instructor complains that R is slow while creating a for loop). With Ruby there is also Rails, so maybe there would be possibility to bring both together as well (Python does have Django, but again I'm not getting into that).

So, the question stands the same, but for my interest, in Ruby:

  • What can you recommend if I wanted to use Ruby as a "statistics workbench" to replace R, SPSS, Python, Excel etc.?

  • What would I gain and lose, based on your experience?

Please note I am considering this question based on the previous Python and Excel question. If you believe using Ruby and Python (or Excel) would have the same impact, then please say so and point to the arguments of any previous question, the intent of this question is not to replicate the previous questions for the same answers. I do, however, believe that there are differences (such as the speed of the language and the syntax), but I would also specially like to know the recommendations for Ruby or if there is, for example much less available for it than say for Python or Excel. So please consider the previous answers for these very similar questions but for other language/program.

Edit: Just to highlight since the answers seems to be going on the other way, the answer that I was looking for is one such as the chosen answer at the Python question I have linked to. It is not about learning statistics together with Ruby. I did point to the question learn statistics with R. If it is possible great, but I am not expecting to learn statistics with Ruby at the same time. You can assume statistics background for this question.

  • $\begingroup$ thanks for edit! I notice my thanks was wiped out. Is it a bad idea to say thank you on the questions? (Just would like to confirm, no problem on my side -- comment a little off topic of the question, but I didn't want to start a question on meta just for this). $\endgroup$ Commented Apr 5, 2012 at 14:55
  • 1
    $\begingroup$ Opinions differ a little. A brief "Thank you" at the end of a question is common, but more than that is usually considered an unnecessary distraction. You can quickly find guidance on the site-wide meta site, such as the SE FAQ page. $\endgroup$
    – whuber
    Commented Apr 5, 2012 at 15:37

3 Answers 3


I'm use Ruby+R.

You can read the paper: RinRuby: Accessing the R Interpreter from Pure Ruby


and this blog:



(sciruby 's author is also R user. )

  • $\begingroup$ Thank you, your answer goes on the direction on what I am looking for. I noticed that the references dates from 2009 and 2011, I wonder if there is more recent literature about this given ruby is a considerable new language and always growing? Still, I guess this is a nice starting point. Nice that the blog consider ruby for scientific research, which exactly is my case. $\endgroup$ Commented Apr 6, 2012 at 18:03
  • $\begingroup$ Hi, I love ruby and rails. I love R too. You can find rubygems Increase more and more. rubygems.org/stats R also too. 2003, R cran is 200, now is 3600+ !!! in 2011, Ruby gem is 28000, now is 36874 gem ! You can enjoy Ruby+R:D $\endgroup$
    – ouyang
    Commented Apr 6, 2012 at 18:06
  • $\begingroup$ Great point on the ruby gems, I forgot about those. Perhaps other people can suggest few ruby gems on the matter of using Ruby as a workbench which are well known to work and are robust? Thanks for adding up an answer on what I am looking for again. $\endgroup$ Commented Apr 6, 2012 at 20:02


If you think you'll learn statistics by programming everything yourself, I'd say you're in for a long slog full of debugging and not statistical learning. Plus, you'll need a language like R to check your answers anyhow.

I think user765195 has a point in terms of R being harder to debug than many other languages, which is important, but "worst"? I don't think so.


So if I can summarize your EDIT: given that you already do statistics, and given that you really want to use Ruby to do it instead of an actual statistical program (R, gretl, SAS, etc), how can you make your life easier. Is that right?

I can't give a Ruby answer, but I think the general question should also be addressed. Especially since you're pointing back to other instantiations of the same question: "I'd like to use Python/perl/java/Clojure/C/whatever to do statistics".

I think the answer will always be: "why use a generalized, primitive (statistics-wise) tool to do a job that a specialized tool does much better?" And I can see six basic replies:

  1. I simply don't want to learn another language, and since I'm well-versed in Python/Ruby/Excel/Java, I insist on using that language.

  2. The statistics I want to do have to fit into a larger project (such as a web-based tool) and the tools used by this project don't play nice with outside tools, so I have to use Python/Ruby/Java. (Or it might be a matter of deploying an application and it's not possible to try to deploy arbitrary executables.)

  3. I would use a specialized tool, but the ones I have access to (say R, which is free) are too slow or cannot handle the huge datasets/real-time requirements for my project.

  4. My employer/client insists I use general-purpose language Python/Ruby/Excel/Java. I have no choice, and am looking for the least painful way to follow this requirement.

  5. By "statistics" I mean very simple stuff like finding means/medians, variances, etc. Why pull in a specialized package that can calculate mixed-effect models via MCMC when all I want to do is calculate what points are outside of 1-sigma away from the mean?

  6. I am doing something very specialize, and for which even statistical packages like R have no packages/libraries/functions. It's not only cutting-edge, but requires super-high performance, and I need to do it from scratch. (Or perhaps use libraries I've developed already in language X.)

In my opinion, reply 1 isn't a good one, reply 2 might be legitimate, but may have workarounds you're not aware of, reply 3 is more likely to be legitimate but also may have workarounds, and for the other three replies, hopefully you'll get a better answer than mine.

  • $\begingroup$ The goal in this question is not to learn statistics together with ruby, please see the edit, but thank you for your thoughts and sorry if the question is misleading I hope it is clear now on the edit. $\endgroup$ Commented Apr 6, 2012 at 14:54
  • $\begingroup$ Thank you, you got it right. Assumption on statistics knowledge is fine, and now I am looking on libraries to learn how to do that in Ruby, such as it were suggested for Python. I agree with you, many motivations are possible, but again (just for the sake of the next readers that come across this page), the expected answer is one that suggests libraries and such as it were mentioned on the Python question. I believe that if there is space for many different opinions about which statistics tool to use, there is also to make knowledge available about them on this community. Thanks! $\endgroup$ Commented Apr 6, 2012 at 17:38
  • $\begingroup$ +1. Most likely, we are talking about different words spelled "statistics". Website usage statistics that can be easily pulled from logs using Python or Ruby is a different animal than say having to program Cox model or the variance of the ratio estimator of a total based on a two-stage stratified survey using Ruby. (One would have to be absolutely desperate along the lines of your answers 2, 3 and 4 to even think about Ruby as the language of choice.) One can supplement their learning statistics with simulations in whichever language is the most convenient, and then 1 is a valid answer. $\endgroup$
    – StasK
    Commented Apr 6, 2012 at 18:11
  • $\begingroup$ @OeufcoquePenteano: In the end, I think my issue boils down to "workbench". The winning answer in the Python thread is actually pretty spartan. All of the listed resources combined don't even match base R, much less thinking about R packages. If you HAVE to do some statistics in Python, you have a few limited options, but one shouldn't be confused and think that Python makes a good statistical "workbench". I hope you get some answers, but Ruby is even worse off than Python. $\endgroup$
    – Wayne
    Commented Apr 6, 2012 at 22:01
  • $\begingroup$ @Wayne, that is fine. I am not planning to exchange R for Ruby, Python or Excel. But I am curious to know what Ruby has to offer. Maybe few gems from Ruby are better than certain eggs (is that egg that they call on Python? Not sure), and vice-versa. Maybe Excel is better for few things. For instance, I think Excel could help on doing some very superficial analysis and then to get serious dive into R or other tool. So, it is not a matter of 'choosing one', but know what is best of each world and knowing them, choose the one that is more appropriate for the given problem. Thanks for your advice. $\endgroup$ Commented Apr 6, 2012 at 23:09

A few random thoughts:

  • You mention that you're looking for a workbench to learn statistics. IMHO, none of the platforms you mention will be good for learning statistics. There will be too much distraction, learning the syntax and the semantics of the specific language. If you want to learn statistics, just pick up a book (I highly recommend Tukey's EDA), and perhaps a calculator. Learning a language on top of statistical concepts is a highly unnecessary distraction.
  • The person who complains about slow loops in R is betraying his ignorance: loops are not a natural construct in every language. They're slow in most functional programming languages. The alternative is function application, and that's usually fast.
  • When it comes to programming languages, speed should be your last concern. A much, much more important issue is the ease to debug the code.
  • When it comes to debugging, R is perhaps the worst programming language I know. It is sometimes impossible to debug the code. On top of that, the documentation for existing packages is usually very poorly written. Overall, my advice is, if you can avoid R, do it.
  • I'm only marginally familiar with Python's statistical content. My understanding is that NumPy is not really professionally written and doesn't take numerical issues into consideration.
  • Have you considered Haskell? It's definitely the best programming language out there.
  • $\begingroup$ Hello! Thank you for your opinion. I'm happy to see a different opinion against R. I will take into consideration what you are saying as well, since I am also looking into other tools not mentioned here. Maybe my question was misleading. I am still learning statistics, and in fact my question regarding R was about this, but for Ruby it is something different. I am curious to see what is available for ruby as a workbench such as it is available for python and excel. I will also consider looking into Haskell, but if you have any suggestions regarding Ruby, I would also appreciate! Thank you! $\endgroup$ Commented Apr 6, 2012 at 5:13
  • $\begingroup$ Haskell for statistics? Talk about an unnecessary distraction... $\endgroup$ Commented Apr 6, 2012 at 17:35
  • $\begingroup$ -1, imposible to debug code in r? $\endgroup$
    – mpiktas
    Commented Apr 6, 2012 at 18:35
  • $\begingroup$ I should note, that only the paragraph about debugging in R is not right in this answer. Everything else seems deserving an upvote. Except Haskell, which I do not have any experience. But the note about debugging is spot on. $\endgroup$
    – mpiktas
    Commented Apr 7, 2012 at 20:06
  • 1
    $\begingroup$ @cpcloud: The language of mathematics and statistics is lambda-calculus. Haskell is nothing but lambda-calculus. Mathematical constructs are expressed in Haskell in exactly the same way as they're written in a mathematics book. Because of that, the overhead from the language is almost zero. In fact, the book "The Haskell Road to Logic" teaches mathematics by using Haskell. I suggest you take a look at that book. $\endgroup$
    – user765195
    Commented Apr 8, 2012 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.