Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate statistics on arrays

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?

like image 959
slykat Avatar asked Nov 26 '12 07:11

slykat


People also ask

How do you find the stats of a NumPy array?

Another useful feature of numpy arrays is the ability to run summary statistics (e.g. calculating averages, finding minimum or maximum values) across the entire array of values. For example, you can use the np. mean() function to calculate the average value across an array (e.g. np. mean(array) ) or np.

How do you find the average of two arrays?

We just have to get the sum of corresponding array elements and then divide that sum with the total number of arrays.

What is array in data analytics?

An array is a linear data structure that collects elements of the same data type and stores them in contiguous and adjacent memory locations. Arrays work on an index system starting from 0 to (n-1), where n is the size of the array.

How do you find the max and min value of a NumPy array?

amax() will find the max value in an array, and numpy. amin() does the same for the min value.


2 Answers

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.

like image 104
ezkl Avatar answered Sep 29 '22 18:09

ezkl


You might be able to use Rubystats or Easystats. I'm sure there's more gems out there I don't know about.

like image 35
Amadan Avatar answered Sep 29 '22 19:09

Amadan