[Numpy-discussion] Re: savetxt() has fmt='%.18e' as default, but fmt='%.16e' is always sufficient

2023-11-27 Thread Sam Mason
On Mon, 27 Nov 2023 at 17:19, Jeppe Dakin  wrote:
> > But if your true concern is that 9% of disk space,
> > you probably don't want to be using `savetxt()` in any case.
> Well, I do in fact want to save as text, but I would rather not do so in an 
> unnecessarily wasteful fashion.

`fmt='%s'` might be a good option if you want to save space:
1. it will output the nearest decimal value that round-trips
2. it handles the case of 32bit floats needing half as many digits
3. it does the right thing for integer values

  Sam
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] should random.standard_t allow df=inf?

2022-08-12 Thread Sam Mason
Hi,
I've just stumbled across a somewhat strange behaviour when I evaluated:

  np.random.standard_t(np.inf)

and got NaN back. The limit of df going to infinity in Student's
t-distribution is a Gaussian, so I'd expect a Gaussian variate back
(but I suppose a warning or error could be argued to be valid).  Note
that R explicitly supports this[1] and results in Gaussian
behaviour[2].

It looks relatively easy to modify random_standard_t (in
distributions.c) to get similar behaviour, but wanted to check if this
behaviour was deliberate before opening an issue.

In fact it looks like the precision of doubles limit df > ~1e35 to be
Gaussian[3], which might compile down to something smaller than a call
to isfinite() as well as catching more cases[4].

Thanks!

  Sam

[1] https://search.r-project.org/R/refmans/stats/html/TDist.html
[2] R source, src/nmath/rt.c, src/nmath/dt.c, etc.
[3] np.random.gamma(1e35, size=100) - 1e35
[4] https://godbolt.org/z/KcvY8sKd3
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com