saghm / very-ants

Probabilistic integer arithmetic for Ruby
MIT License
31 stars 0 forks source link

There is actual vaule in probablistic calculations #2

Open MadBomber opened 8 years ago

MadBomber commented 8 years ago

You might consider refactoring your idea into a different kind of number class... maybe class Varnum < Fixnum and class Sink < Float. This would allow an application to still use true results for some known conditions and your vary-ants for those unknown probabilistic conditions.

saghm commented 8 years ago

This library wasn't actually intended to be useful for any real applications. While probabilistic calculations are undoubtedly useful, I'm struggling to think of any use case for the very crude sort of randomization in this implementation; most of the probability calculations that need to be done in programming would probably be better suited to be done by more sophisticated functionality.

I mainly decided to override the methods in Fixnum so that typing literal expressions like 3 * 4 - 5 would be performed ants-ily. Having to write that as antsy_minus(antsy_times(3, 4), 5) seemed like a lot of work for what is essentially a joke. I suppose that doing 3.antsy * 3.antsy - 5.antsy would be a decent improvement, but I guess I'm still wondering what exactly anyone would want to use VeryAnts for in a real application. That being said, if people think this is a better idea, I'm totally fine with doing this. Would people prefer this? (Or, an even better question, is anyone actually reading this?)

One thing I do notice now in retrospect is that I probably should have at the very least had Fixnum extend VeryAnts::Int rather than include it; that way, one could at the very least have access to Fixnum::plus, Fixnum::minus, etc., where one could specify the custom c as 1 and in that way have a very kludgy way of performing regular arithmetic.

As an aside, I totally love the name Sink for a subclass of Float! I haven't really thought about how to perform antsy arithmetic on floating-point numbers yet though, so that may have to wait a bit.

Thanks a ton for the feedback! I totally wasn't expecting anyone to care enough about this to have an opinion on it, so I'm quite flattered.