![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
davidrichards-just_enumerable_stats
Advanced tools
== Just Enumerable Stats
I had some tricky stuff in Statisticus and Sirb that were useful, but I ended up using someone else's library for plain-old calculations on a single enumerable. What a shame, I thought. So I extracted things out and made a simpler library that I'd use for my simpler needs.
I also included a FixedRange class for traversing floating point ranges a little more easily and a nearly-exact copy of the whole library in its own module for containing these methods in your own container. See the Known Issues section below and the specs for that module.
==Usage
Would I release a gem without an IRB application included? Probably not. This gem has one, and it's called jes:
jes Loading Just Enumerable Stats version: 0.0.1
Looking at the library through jes, you can see that we have all the usual goodies:
[1,2,3].mean => 2 [1,2,3].std => 1.0 [1,2,3].cor [2,3,5] => 0.981980506061966
The list of methods are:
One of the more interesting methods is yield_transpose:
[1,2,3].yield_transpose([5,5,5], [2,2,2]) { |e| e.product }
The yield_transpose:
In this case, it multiplies 1 * 5 * 2, 2 * 5 * 2, and 3 * 5 * 2 to get the final result.
There are a lot of other interesting tools that do this (RNum, Matrix), but the ones I know about aren't as flexible as this simple implementation.
Another interesting feature is the default block getter and setter. Sometimes I need to filter, scale, or normalize a result. I can do that in the default block and still hold on to the original value Ultimately, it's more expensive to do things this way (every computation has to also go through a filter), but it's a little simpler sometimes. An example:
a = [1,2,3] a.default_block = lambda {|e| e * 2} a.sum
a.std
== Scaling
There are a few new features for scaling data:
a = [1,2,3] => [1, 2, 3] a.scale(2) => [2, 4, 6] a => [1, 2, 3] a.scale!(2) => [2, 4, 6] a => [2, 4, 6] a.scale {|e| e - 1} => [1, 3, 5] a => [2, 4, 6] a.scale! {|e| e - 1} => [1, 3, 5] a
=> [1, 3, 5] a.scale_between(3,4) => [3.0, 3.5, 4.0] a => [1, 3, 5] a.scale_between!(3,4) => [3.0, 3.5, 4.0] a => [3.0, 3.5, 4.0] a = [1,2,3] => [1, 2, 3] a.normalize => [0.166666666666667, 0.333333333333333, 0.5] a
=> [1, 2, 3] a.normalize! => [0.166666666666667, 0.333333333333333, 0.5] a => [0.166666666666667, 0.333333333333333, 0.5] a = [-5,0,5]
=> [-5, 0, 5] a.scale_to_sigmoid => [0.00669285092428486, 0.5, 0.993307149075715] a => [-5, 0, 5] a.scale_to_sigmoid! => [0.00669285092428486, 0.5, 0.993307149075715] a
=> [0.00669285092428486, 0.5, 0.993307149075715]
Basically:
== Categories
Once I started using this gem with my distribution table classes, I needed to have flexible categories on an enumerable. What that looks like is:
Loading Just Enumerable Stats version: 0.0.4
a = [1,2,3] => [1, 2, 3] a.categories => [1, 2, 3] a.category_values => {1=>[1], 2=>[2], 3=>[3]} a.set_range_class FixedRange, 1, 3, 0.5 => FixedRange a.categories => [1.0, 1.5, 2.0, 2.5, 3.0] a.category_values(true) => {1.0=>[1], 1.5=>[], 2.0=>[2], 2.5=>[], 3.0=>[3]} a.set_range({ ?> "<3" => lambda{|e| e < 3}, ?> "3" => lambda{|e| e == 3} }) => ["<3", "3"] a.categories => ["<3", "3"] a.category_values(true) => {"<3"=>[1, 2], "3"=>[3]} a.count_if {|e| e < 3} => 2 a.count_if {|e| e == 3} => 1 a.dichotomize(2, :small, :big) => [:small, :big] a.categories => [:small, :big] a.category_values[:small] => [1, 2] a.category_values[:big]
=> [3]
OK, here we go:
==Obtrusiveness
This gem won't override methods, but it puts a lot into the Enumerable namespace. It's almost as abusive as ActiveSupport. I'll be testing this in a Rails environment to make sure this plays nicely with ActiveSupport. The issue there was that ActiveSupport also wanted to override sum on an enumerable. If you are in an environment where jes isn't overriding methods, then you're going to have to use the jes prefix for the calls. So, @a._jes_sum will work, as will @a._jes_standard_deviation, @a._jes_covariance, etc. I'm realizing that I always want to use this library in all of my new stuff, because it simplifies things so much. So, this is going to be an ever-more important point.
==Installation
sudo gem install davidrichards-just_enumerable_stats
== Dependencies
There's an optional dependency on facets/dictionary. You'll have fewer surprises if you use a Dictionary instead of a hash for categories.
== Known Issues
==COPYRIGHT
Copyright (c) 2009 David Richards. See LICENSE for details.
FAQs
Unknown package
We found that davidrichards-just_enumerable_stats demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.