##-*- org -*-->  Emacs .. [Tab] key + [Org] menu; C-c C-o to follow links

* TODO pbeta() approximations notably for log scale where bpser underflows to -Inf <<<<<<<<<<<
** TODO MM has had a pure R  bratio() for TOMS 708 in	~/R/MM/NUMERICS/dpq-functions/beta-gamma-etc/toms708-bratio.R
***		including also (very unfinished)	~/R/MM/NUMERICS/dpq-functions/beta-gamma-etc/toms708-regions.R
* DONE *Embarrassing*: both qnormUappr() & qnormUappr6() were *negative* (wrong sign), for lp in [-.69, 0)
* DONE Provide R functions interfacing to the "applied math utilities" in ./src/DPQ-misc.c : ./R/utils.R
* DONE Add pgamma_1006() using the 2020  TOMS Algorithm 1006 === ~/src/TOMS/1006-inc_gamma/
* DONE Have gam1d() now (calling C - TOMS 708) -- but also want to add the "pure R" version in ./TODO_R_versions_gam1_etc.R
** gam1() now calls gam1d() or mpfr-ized code;  similarly new gamln1() now calling old gamln1.() or mpfr-ized code
* TODO Compare pnchi1sq() with t1() function in tests/chisq-nonc-ex.R
* TODO Computational Statistics paper ~/save/papers/Numerics/noncentral_gamma_deOliveira+Ferreira_ComputStat_2013.pdf
   de Oliveira, I.R.C and Ferreira, D.F. (2013)
   Computing the noncentral gamma distribution, its inverse and the noncentrality parameter
   Comput Stat 28:1663–1680 -- \doi{10.1007/s00180-012-0371-8}
 --> CRAN package `ncg` (non-central gamma) https://cran.r-project.org/src/contrib/Archive/ncg/
  showing
  	ncg_0.1.0.tar.gz	2012-06-19 08:43 	4.2K
  	ncg_0.1.1.tar.gz	2012-07-05 15:40 	4.1K -- Maintainer Daniel Ferreira
  was archived on CRAN: "Archived on 2022-05-09 as email to the maintainer is undeliverable."
  https://cran-archive.r-project.org/web/checks/2022/2022-05-09_check_results_ncg.html
     --> unpacked, "fixed" -> Version 0.1-2 --> ~/R/Pkgs/ncg/DESCRIPTION
   slightly add *some* of these functions to DPQ ? === R-code only -- *not*
   sophisticated, but a valid "baseline" .. *Actually* in their performance
   part they find cases where their method ("PM" := proposed method) is better than R ("RM") !!
   --> ~/R/Pkgs/ncg/ || Mlibrary(ncg) -- ~/R/Pkgs/ncg.Rcheck-64b/ncg

* TODO Add qnchisq{Approx} -- also from "the book" JKK vol.2, chapter 29 -- e.g. Pearson and other

   we have all the pnchisq{Approximations} but not much from their inverse x_p(..)
* TODO Newer (than de Oliveira & Ferreira (2013) paper on  gammaCHI Software
       gives *better* approximations (at least in parts):
  - Gil, Amparo; Segura, Javier; Temme, Nico M. (2021),
     “GammaCHI: A package for the inversion and computation of the gamma and
      chi-square cumulative distribution functions (central and noncentral).
      New version announcement”,  [Computer Physics Communications 267 (2021) 108083]
      https://doi.org/10.1016/j.cpc.2021.108083
    CPC Library link to program files:
      https://doi.org/10.17632/d2kwwvsyny.1 (see below)
       == https://https://data.mendeley.com/datasets/d2kwwvsyny/1 --> GSTNVA2021.zip (85625 bytes)
  - [First version of software with "original" good paper:]
     Amparo Gil and Javier Segura and Nico M. Temme (2015)
     GammaCHI: A package for the inversion and computation of the gamma and chi-square
               cumulative distribution functions (central and noncentral)
     Computer Physics Communications 191, 132–139
     http://dx.doi.org/10.1016/j.cpc.2015.01.004
    MM (nb-mm5): 1.  ~/src/GammaCHI/ --- the code is quite readable, but *NOT* translateable with f2c
                 2. our stirlerr() function is ~= (?) ~= their  stirling() function  !!

* DONE in R >= 4.0.0, now .Machine has 10 "longdouble.*" components (when the configuration found long double)
  Note that from `#include <float.h>` we should just return the `LDBL_*` values.
* TODO tests/chisq-nonc-ex.R : move "things" to a vignette -- DONE partly : vignettes/Noncentral-Chisq.Rnw
* TODO tests/qbeta-dist.R    : move "things" to a vignette
* TODO vignettes/comp-beta.Rnw: change to use same 'jss' * \cite*{} etc as ~/R/Pkgs/lme4/vignettes/lme4.Rnw
* TODO b_chi(): Now have higher order asymptotic expansion *and* confirmed via Rmpfr that it is
  much better than internal b2(), we should use its higher order
  down to ~200 and completely "drop" b2() and redefine an optimal c1.
  see R/t-nonc-fn.R and notably man/b_chi.Rd
** TODO in R/t-nonc-fn.R : also have c_dt() etc, based on lb_chi() which needs to be defined,
  using lb_chiAsymp(nu, order) vs lb_chi0() switch()ing depending on
  desired precision (dblpr *and* "mpfr") and nu itself
* TODO t-distributions (notably *noncentral*, "pnt" etc):
* TODO tests/pnt-prec.R : *label* the 391 plots: tests/pnt-precision-2.pdf
* TODO tests/pnt-prec.R : some parts only if(doExtras)
** TODO extract some useful functions from our tests/pnt-prec.R
** TODO extract functions (and "tests") from ~/R/MM/NUMERICS/dpq-functions/dt-ex.R
** TODO extract fns & tests   from ~/R/MM/NUMERICS/dpq-functions/pt-ex.R
** TODO extract fns & tests   from ~/R/MM/NUMERICS/dpq-functions/qt-ex.R
* TODO add dgamma.R() vs dgamma() checks to tests/*.R
  NB  >> ./man/dgamma.R.Rd

** TODO: Implement Chattamvelli, R. and Shanmugam, R. (1994) --> pntChShP94()
   ~/save/papers/Numerics/Chattamvelli+Sh_noncentr-t_1994.pdf
   Chattamvelli, R. and Shanmugam, R. (1994)
   An enhanced algorithm for noncentral T-distribution
   \emph{Journal of Statistical Computation and Simulation} \bold{49}, 77--83
   \doi{10.1080/00949659408811561}
* TODO chisq-Wienergerm approximations: >>>>> ./wienergerm_README <<<<<<<<<
** TODO move C code to here
** TODO Find documentation / papers ==> for help pages about h() and g() in R/wienergerm_nchisq-fn.R
* TODO non-central beta (AS 310): more experiments (cf with R's older algo) --> R/pnbeta.R
* TODO src/qchisq_appr.c / init.c : change to .Call() version which vectorizes in both args
* TODO tests/qbeta-dist.R : Demonstrates clear *bug* in R's qbeta() incl 'NOTIFY R-core!'

* TODO tests/qbeta-dist.R (2): Shows how to compute  log(p*Beta(p,q)) accurately for p << q  very nice plots <=??=> Qab(), algdiv()??

* TODO tests/qPoisBinom-ex.R:  *FIX* Bug in qpois / qbinom / qnbinom upper.tail|log.p

* DONE ~/R/MM/NUMERICS/dpq-functions/dbinom_raw.R also has dnbinom.mu() ==> provide also dnbinomR()

* DONE tests/chisq-nonc-ex.R : use result file in inst/safe/  -- parts only if(doExtras)
* DONE tests/qbeta-dist.R    : use result file in inst/safe/  -- parts only if(doExtras)
* DONE tests/qgamma-ex.R     : some parts only if(doExtras)
* DONE ppoisErr() should use 'long double'; get an 'all_from_0' option that works like cumsum(dpois(0:n))
* DONE Document these (or do _not_ export):  now --> man/pnchisqWienergerm.Rd
  NB <--> ./wienergerm_README <<< ./R/wienergerm_nchisq-fn.R ./tests/wienergerm_nchisq.R
 ‘g2’ ‘gnt’ ‘h’ ‘h0’ ‘h1’ ‘h2’ ‘hnt’ ‘newton’ ‘p.dnchiB’ ‘ss’ ‘ss2’ ‘ss2.’
* DONE Rename 'err.lambd*()' to 'ppoisErr*()';  put on same help page as ppoisD(); further
** DONE : only when verbose=TRUE, they still print
* DONE lbeta.n(), lbeta.asy() .. __rename__;  add the two  *Qab*() functions to help page  man/lbeta.Rd
* DONE qnormU*(): is "upper tail" qnorm ==>  use default arg  lower.tail=FALSE (but keep log.p=FALSE)
* DONE s() is too short, not ok.  Maybe s_() or s.() ? --> using sW() now
* DONE qchisq.appr.R() in R/qgamma-fn.R and qchisq.appr.Kind() are almost identical:
  kept qchisq.appr.R(), renamed to qchisqAppr.R(); the *.R() version is vectorized and used in qgamma.R()
* DONE dcdflib -- ===> made into separate package (part of same R-forge project 'specfun')
