ENH: avoid repeated matrix inverse

The `sum_cov` term doesn't change, so it's faster to use a factorized version and solve.
BUG: use correct MAXGAM in beta.c

AFAICT the correct constant is used everywhere in cephes.

Also try harder to use the best order of operations when
calculating beta from gammas.
BUG: don't try to calculate beta in betainc, just call it.

fixes gh-3761
TST: lombscargle regression test related to atan vs atan2
MAINT: put more classes back into the scipy.stats.distributions namespace
MAINT: attempt py3 compatibility fix
Merge pull request #3803 from argriffing/lombscargle-atan2-test

TST: lombscargle regression test related to atan vs atan2
MAINT: move redundant code into a function
MAINT: add code comment and make a small code change
BUG: numpy version checking in ndimage
Merge pull request #3806 from argriffing/ndimage-numpy-version

BUG: numpy version checking in ndimage
Merge pull request #3804 from argriffing/stats-gen-api

MAINT: put more classes back into the scipy.stats.distributions namespace
Merge pull request #3779 from ewmoore/incbet_fix

BUG: special: fix overflow problems in betainc, and improve precision of beta

Fixes gh-3761
Merge pull request #3769 from perimosocordiae/patch-5

ENH: avoid repeated matrix inverse