In the standard Math module there is a gamma method.
Where can I see the code of this function for modification, or is there a ready upper gamma function?
Actually, in the math.rb file only:

  def self.gamma(x) #This is a stub, used for indexing end 
  • Do you want to find a function of two variables (incomplete) , and not Math.gamma() ? - jfs
  • Exactly! If not found, then modify it. Math.gamma - QWD666
  • But only with other limits. from z to infinity - QWD666

1 answer 1

In MRI (reference Ruby, which you most likely use), it is written in C, looks like this now, and if you examine its code, you can see that this is just a wrapper over the tgamma function from the standard library C , and that it doesn’t implement the mathematics on its own .

No, there is no ready top gamma function in the standard Ruby library. You can search in gems. Good candidates are rubystats and wrappers over the GNU Scientific Library (GSL). And, of course, you can write yourself.

  • very difficult. Yes, most likely the MRI is worth it, because it doesn’t bother ruby -v gives ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu] . The sources from C are of little concern. rubystats glanced, but something scares me there. and it seems like there did not find the right one. Well, if you put the question differently, how to implement the integration process? - QWD666
  • @ QWD666 the calculation of many convergent things from matan is based on something iterative, which with every step of the cycle gives results more and more accurately, but at some point it sticks to the ceiling of double precision and there’s no point in counting further. In rubystats your function is, implemented through the sum of the "infinite" series, as far as I can tell. - D-side
  • It seems to be true, but unfortunately not a working version. - QWD666
  • @ QWD666 in rubystats it works: D - D-side
  • That is, simply by pulling out the function, will it not fly up? Strange enough, okay, I put heme - QWD666