Metadata-Version: 2.4
Name: gsl-rstat
Version: 1.0
Summary: Python wrapper around GNU GSL 2.8 running statistics
Author-email: Lee Benson <lee.benson@stfc.ac.uk>
License: Copyright (c) 2026 UKRI STFC Central Laser Facility
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of
        this software and associated documentation files (the “Software”), to deal in
        the Software without restriction, including without limitation the rights to
        use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
        of the Software, and to permit persons to whom the Software is furnished to do
        so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Requires-Python: >=3.13.2
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: numpy; extra == "test"
Requires-Dist: scipy; extra == "test"
Requires-Dist: matplotlib; extra == "test"
Dynamic: license-file

# gsl-rstat

Python wrapper around [GNU GSL 2.8 running statistics](https://www.gnu.org/software/gsl/doc/html/rstat.html).

## Installation

This package depends on the gsl_rstat_* and gsl_rstat_quantile_* functions declared in ```gsl_rstat.h```, provided by the GNU Scientific Library (GSL) v2.8.  Since this package provides only a thin wrapper around these functions, you'll need both the GSL v2.8 binaries and headers installed on your system before you can install and use it.  For Debian 13 (Trixie) and Ubuntu 25.0 (Questing Quokka) you can get these from the package repos.  E.g., using apt

```
apt-get update && apt-get install libgsl-dev gsl-bin
```

If v2.8 is not available via the package repos for your distribution, you'll need to build these from source.  In such a scenario, either ensure that both the headers and binaries `libgsl.so` and `libgslcblas.so` are either in one of the standard locations on your system, or point your compiler and linker to the appropriate places, e.g., by setting the following environment variables

```
export CFLAGS="${CFLAGS} -I/path/to/gsl-headers"
export LDFLAGS="${LDFLAGS} -L/path/to/libgsl.so -L/path/to/libgslcblas.so"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/path/to/libgsl.so:/path/to/libgslcblas.so"
```

Finally,

```
($) python -m venv .venv
($) . .venv/bin/activate
($) pip install --upgrade pip && pip install gsl-rstat

```

## Usage

See the [GNU GSL documentation](https://www.gnu.org/software/gsl/doc/html/rstat.html) for the available running statistics & their definitions

```python
from gsl_rstat import RStat, RStat_Quantile

my_rstat = RStat()
my_rstat_quantile = RStat_Quantile(0.3)

my_rstat.add(22)
my_rstat.add(443.5)

my_rstat_quantile.add(12)
my_rstat_quantile.add(-22.)
my_rstat_quantile.add(443.2)

print(f"n = {my_rstat.n}, mean = {my_rstat.mean}, rms = {my_rstat.rms}")
print(f"30% quantile = {my_rstat_quantile.get()}")

my_rstat.reset()
my_rstat_quantile.reset()
```

## log.c
This project uses `log.c` by [rxi](https://github.com/rxi/log.c/) to optionally log C struct heap allocations and deallocations.  To enable
add `-DLOGGING` to the `CFLAGS` environment variable when building the package from source

```
export CFLAGS="${CFLAGS} -DLOGGING"
```


## Build GNU GSL v2.8 from source

To do

