pyrenyi 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyrenyi-0.1.0/CHANGELOG.md +21 -0
- pyrenyi-0.1.0/CITATION.cff +26 -0
- pyrenyi-0.1.0/LICENSE +21 -0
- pyrenyi-0.1.0/MANIFEST.in +5 -0
- pyrenyi-0.1.0/PKG-INFO +394 -0
- pyrenyi-0.1.0/README.md +359 -0
- pyrenyi-0.1.0/examples/periodic_box.py +58 -0
- pyrenyi-0.1.0/examples/survey.py +52 -0
- pyrenyi-0.1.0/pyproject.toml +47 -0
- pyrenyi-0.1.0/setup.cfg +4 -0
- pyrenyi-0.1.0/src/pyrenyi/__init__.py +16 -0
- pyrenyi-0.1.0/src/pyrenyi/_common.py +103 -0
- pyrenyi-0.1.0/src/pyrenyi/_grid.py +51 -0
- pyrenyi-0.1.0/src/pyrenyi/_kernels.py +515 -0
- pyrenyi-0.1.0/src/pyrenyi/catalogue.py +88 -0
- pyrenyi-0.1.0/src/pyrenyi/cli.py +313 -0
- pyrenyi-0.1.0/src/pyrenyi/fixed_mass.py +418 -0
- pyrenyi-0.1.0/src/pyrenyi/fixed_radius.py +385 -0
- pyrenyi-0.1.0/src/pyrenyi/io.py +184 -0
- pyrenyi-0.1.0/src/pyrenyi/mocks.py +86 -0
- pyrenyi-0.1.0/src/pyrenyi/regions.py +52 -0
- pyrenyi-0.1.0/src/pyrenyi/results.py +162 -0
- pyrenyi-0.1.0/src/pyrenyi.egg-info/PKG-INFO +394 -0
- pyrenyi-0.1.0/src/pyrenyi.egg-info/SOURCES.txt +31 -0
- pyrenyi-0.1.0/src/pyrenyi.egg-info/dependency_links.txt +1 -0
- pyrenyi-0.1.0/src/pyrenyi.egg-info/entry_points.txt +2 -0
- pyrenyi-0.1.0/src/pyrenyi.egg-info/requires.txt +22 -0
- pyrenyi-0.1.0/src/pyrenyi.egg-info/top_level.txt +1 -0
- pyrenyi-0.1.0/tests/conftest.py +8 -0
- pyrenyi-0.1.0/tests/data/paper_dq_reference.npz +0 -0
- pyrenyi-0.1.0/tests/reference.py +193 -0
- pyrenyi-0.1.0/tests/test_core.py +344 -0
- pyrenyi-0.1.0/tests/test_io_cli.py +212 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-10-18)
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
* Fixed-radius estimators of the Renyi generalised dimensions: point-centred
|
|
8
|
+
and volume-weighted, in spheres, in shells beyond a minimum separation, and
|
|
9
|
+
in |mu| wedges about a fixed or observer-based line of sight.
|
|
10
|
+
* Periodic boxes (analytic expectation) and surveys (expectation from a
|
|
11
|
+
weighted random catalogue), with weights and marks, an edge cut, and
|
|
12
|
+
delete-one jackknife errors.
|
|
13
|
+
* Finite-sample corrections: Grassberger's for unit weights, and its weighted
|
|
14
|
+
generalisation (elementary symmetric polynomials), both exact for integer
|
|
15
|
+
q; Poisson-unbiased normalisation by the random counts.
|
|
16
|
+
* Fixed-mass (nearest-neighbour) estimator, free of discreteness bias at
|
|
17
|
+
every q.
|
|
18
|
+
* File readers (ASCII, npy, npz, FITS, HDF5) and a command-line interface
|
|
19
|
+
driven by TOML configurations.
|
|
20
|
+
* Test point sets: Poisson, deterministic and random multiplicative cascades
|
|
21
|
+
with exact D_q.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite the paper below and the software."
|
|
3
|
+
title: "PyRenyi: Renyi generalised dimensions of point distributions"
|
|
4
|
+
type: software
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
date-released: 2026-10-18
|
|
7
|
+
license: MIT
|
|
8
|
+
repository-code: "https://github.com/csabiu/PyRenyi"
|
|
9
|
+
authors:
|
|
10
|
+
- family-names: Sabiu
|
|
11
|
+
given-names: Cristiano G.
|
|
12
|
+
affiliation: University of Seoul
|
|
13
|
+
keywords:
|
|
14
|
+
- multifractal
|
|
15
|
+
- generalised dimensions
|
|
16
|
+
- large-scale structure
|
|
17
|
+
- cosmology
|
|
18
|
+
preferred-citation:
|
|
19
|
+
type: article
|
|
20
|
+
title: "Cosmological Information in the Rényi Generalised Dimensions of the Large-Scale Distribution of Haloes and Galaxies"
|
|
21
|
+
authors:
|
|
22
|
+
- family-names: Sabiu
|
|
23
|
+
given-names: Cristiano G.
|
|
24
|
+
journal: "Journal of the Korean Astronomical Society"
|
|
25
|
+
year: 2026
|
|
26
|
+
notes: "Submitted"
|
pyrenyi-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cristiano G. Sabiu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pyrenyi-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyrenyi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Renyi generalised dimensions D_q of point distributions, for periodic boxes and surveys with randoms and weights
|
|
5
|
+
Author: Cristiano G. Sabiu
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/csabiu/PyRenyi
|
|
8
|
+
Project-URL: Issues, https://github.com/csabiu/PyRenyi/issues
|
|
9
|
+
Keywords: multifractal,generalised dimensions,Renyi entropy,large-scale structure,galaxy clustering,point processes,cosmology
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: numpy>=1.21
|
|
19
|
+
Requires-Dist: scipy>=1.7
|
|
20
|
+
Requires-Dist: numba>=0.55
|
|
21
|
+
Requires-Dist: tomli>=1.1; python_version < "3.11"
|
|
22
|
+
Provides-Extra: fits
|
|
23
|
+
Requires-Dist: astropy>=4.0; extra == "fits"
|
|
24
|
+
Provides-Extra: hdf5
|
|
25
|
+
Requires-Dist: h5py>=3.0; extra == "hdf5"
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest>=6; extra == "test"
|
|
28
|
+
Requires-Dist: astropy>=4.0; extra == "test"
|
|
29
|
+
Requires-Dist: h5py>=3.0; extra == "test"
|
|
30
|
+
Provides-Extra: all
|
|
31
|
+
Requires-Dist: astropy>=4.0; extra == "all"
|
|
32
|
+
Requires-Dist: h5py>=3.0; extra == "all"
|
|
33
|
+
Requires-Dist: matplotlib>=3.3; extra == "all"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# PyRenyi
|
|
37
|
+
|
|
38
|
+
Rényi generalised dimensions $D_q$ of point distributions, in periodic
|
|
39
|
+
simulation boxes and in surveys with random catalogues and weights.
|
|
40
|
+
|
|
41
|
+
The generalised dimensions describe how the moments of the mass around each
|
|
42
|
+
point scale with radius. With $p_i(r)$ the fraction of the points within $r$
|
|
43
|
+
of point $i$,
|
|
44
|
+
|
|
45
|
+
$$Z_q(r) = \langle p_i(r)^{q-1} \rangle_i, \qquad
|
|
46
|
+
Y_q(r) = \frac{\ln Z_q(r)}{q-1}, \qquad
|
|
47
|
+
D_q(r) = \frac{d Y_q}{d \ln r}.$$
|
|
48
|
+
|
|
49
|
+
Orders $q > 1$ weight the dense regions and $q < 1$ the empty ones; a
|
|
50
|
+
homogeneous distribution has $D_q = 3$ at every $q$. PyRenyi provides
|
|
51
|
+
estimators that are free of the discreteness bias of the naive moments where
|
|
52
|
+
that is possible, and that work in arbitrary survey geometries.
|
|
53
|
+
|
|
54
|
+
* **Fixed-radius estimators**: point-centred (the centres sample the measure)
|
|
55
|
+
and volume-weighted (the centres fill the volume), in spheres, in shells
|
|
56
|
+
beyond a minimum separation, and in $|\mu|$ wedges about the line of sight.
|
|
57
|
+
* **Fixed-mass estimator**: from the radii that hold $k$ neighbours; it has no
|
|
58
|
+
discreteness bias at any $q$, including $q < 1$.
|
|
59
|
+
* **Periodic boxes** with analytic expectations, and **surveys** with a weighted
|
|
60
|
+
random catalogue, an edge cut and a line of sight from an observer.
|
|
61
|
+
* **Weights and marks**, with a finite-sample correction that stays exact for
|
|
62
|
+
integer $q$.
|
|
63
|
+
* **Jackknife errors and covariances**, file readers (ASCII, npy, npz, FITS,
|
|
64
|
+
HDF5), a command-line interface, and test point sets with exact $D_q$.
|
|
65
|
+
|
|
66
|
+
All inputs are Cartesian positions: convert sky coordinates and redshifts to
|
|
67
|
+
comoving positions first.
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install pyrenyi # numpy, scipy, numba
|
|
73
|
+
pip install "pyrenyi[fits,hdf5]" # + astropy and h5py for the file readers
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
From a clone of this repository:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install -e ".[test]"
|
|
80
|
+
pytest
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The numerical kernels are compiled by numba on first use (about a minute) and
|
|
84
|
+
cached.
|
|
85
|
+
|
|
86
|
+
## Quick start
|
|
87
|
+
|
|
88
|
+
### A periodic box
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import numpy as np
|
|
92
|
+
import pyrenyi
|
|
93
|
+
|
|
94
|
+
L = 1000.0
|
|
95
|
+
w = [0.16, 0.15, 0.14, 0.13, 0.12, 0.11, 0.10, 0.09]
|
|
96
|
+
x = pyrenyi.mocks.random_cascade(300_000, w, levels=10, box=L, seed=1) # exact D_q known
|
|
97
|
+
|
|
98
|
+
radii = 5.0 * 2.0 ** (np.arange(15) / 3.0) # 5 to 127, three per octave
|
|
99
|
+
q = np.arange(-4.0, 6.01, 0.5)
|
|
100
|
+
res = pyrenyi.measure(x, radii=radii, q=q, box=L, r_min=10.0, wedges=3, los='z',
|
|
101
|
+
jackknife=27)
|
|
102
|
+
|
|
103
|
+
D, r = res.dq() # isotropic D_q(r), shape (n_q, n_r - 1)
|
|
104
|
+
Dw, r = res.dq(r_min=10.0, wedge=2) # beyond 10, in the wedge 2/3 <= |mu| <= 1
|
|
105
|
+
err = res.errors(r_min=10.0, wedge=2) # jackknife errors
|
|
106
|
+
C = res.covariance(r_min=10.0) # covariance of the flattened (q, r) array
|
|
107
|
+
print(pyrenyi.mocks.cascade_dq(w, q)) # the exact values
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### A survey
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
data = pyrenyi.Catalogue(galaxy_xyz, weights=w_sys) # Cartesian, with weights
|
|
114
|
+
randoms = pyrenyi.Catalogue(random_xyz, weights=w_ran, nbar=nz_ran) # nbar: data density at each random
|
|
115
|
+
|
|
116
|
+
res = pyrenyi.measure(data, randoms, radii=radii, q=q, r_min=10.0, wedges=3,
|
|
117
|
+
los='midpoint', observer=(0.0, 0.0, 0.0),
|
|
118
|
+
edge_cut=0.8, jackknife=64)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The randoms define the survey geometry and the expected counts; `nbar` gives
|
|
122
|
+
the volume of each random, which the edge cut needs.
|
|
123
|
+
|
|
124
|
+
### Fixed mass
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
fm = pyrenyi.fixed_mass(data, randoms, k=[1, 2, 4, 8, 16, 32, 64, 128], q=q,
|
|
128
|
+
edge_cut=0.8, jackknife=64)
|
|
129
|
+
D, r = fm.dq() # D_q between adjacent k, at their typical radius
|
|
130
|
+
D, r = fm.dq(pairs=[(4, 64)]) # or over any range of k
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Saving
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
res.save('dq.npz')
|
|
137
|
+
res = pyrenyi.load('dq.npz')
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`examples/cascade_dq.ipynb` is a notebook that samples a multiplicative cascade,
|
|
141
|
+
measures $D_q$ with both estimators and plots it against the exact curve (it
|
|
142
|
+
needs matplotlib). `examples/periodic_box.py` and `examples/survey.py` are
|
|
143
|
+
complete, runnable scripts. The survey example builds a mock survey with a radial selection and
|
|
144
|
+
an angular completeness, and recovers the exact $D_q$ of the underlying cascade
|
|
145
|
+
within the errors. The fixed-radius estimator does so at $q < 1$ only where the
|
|
146
|
+
spheres are well occupied.
|
|
147
|
+
|
|
148
|
+
## The estimators
|
|
149
|
+
|
|
150
|
+
### Point-centred, fixed radius
|
|
151
|
+
|
|
152
|
+
`measure(..., estimator='point')` (the default) centres a sphere of radius $r$
|
|
153
|
+
on every data point $i$ and finds the mass of its neighbours (the centre
|
|
154
|
+
excluded). The partition function is the centre-weighted mean
|
|
155
|
+
|
|
156
|
+
$$Z_q(r) = \frac{\sum_i c_i\, T_s(i, r)\, /\, \mu_i(r)^s}{\sum_i c_i},
|
|
157
|
+
\qquad s = q - 1,$$
|
|
158
|
+
|
|
159
|
+
where $T_s$ is the finite-sample-corrected $s$-th power of the neighbour mass,
|
|
160
|
+
$\mu_i$ its expectation for a homogeneous field, and $c_i$ the weight times
|
|
161
|
+
mark of the centre. Then $Y_q = \ln Z_q / (q-1) + \ln[f v(r) / V]$, with $v(r)$
|
|
162
|
+
the sphere volume, $f$ the solid-angle fraction of the wedge and $V$ a reference
|
|
163
|
+
volume that cancels in $D_q$; for $q = 1$, $Y_1 = \langle \psi$-corrected
|
|
164
|
+
$\ln(\text{mass}) - \ln \mu_i \rangle + \ln[f v / V]$. In a periodic box with unit
|
|
165
|
+
weights this is exactly the estimator of Sabiu (2026).
|
|
166
|
+
|
|
167
|
+
### Finite-sample corrections
|
|
168
|
+
|
|
169
|
+
The moments of a discrete sample are biased: for a Poisson count $n$ with mean
|
|
170
|
+
$\lambda$, $\langle n^s \rangle \neq \lambda^s$. With `correction='grassberger'`
|
|
171
|
+
(the default):
|
|
172
|
+
|
|
173
|
+
* unit weights: $T_s = \Gamma(n+1) / \Gamma(n+1-s)$ (Grassberger 1988, 2003),
|
|
174
|
+
whose Poisson mean is exactly $\lambda^s$ for integer $s \ge 0$;
|
|
175
|
+
* weights: $T_s = s!\, e_s(u_1, \dots, u_n)$, the elementary symmetric
|
|
176
|
+
polynomial of the neighbour masses (the sum over distinct $s$-tuples). For
|
|
177
|
+
Poisson sampling of any field its mean is exactly the $s$-th power of the
|
|
178
|
+
expected mass, so the correction stays exact for integer $q \ge 2$ with
|
|
179
|
+
weights;
|
|
180
|
+
* non-integer $s$ with weights: the Gamma-function form with the effective
|
|
181
|
+
count $n_\text{eff} = (\sum u)^2 / \sum u^2$, scaled by $\sum u^2 / \sum u$.
|
|
182
|
+
|
|
183
|
+
`'effective'` uses the last form for every $q$, and `'none'` the plain powers with
|
|
184
|
+
the centre included (the sandbox estimator of Sabiu, Teodoro & Hendry 2007).
|
|
185
|
+
|
|
186
|
+
For $q < 1$ the correction is not exact: at mean counts of a few, the
|
|
187
|
+
point-centred moments of the emptiest spheres are biased low (for a Poisson
|
|
188
|
+
field, $\langle T_s \rangle = \lambda^s P(|s|, \lambda)$). Use radii where the spheres
|
|
189
|
+
hold tens of points, or the fixed-mass estimator.
|
|
190
|
+
|
|
191
|
+
### Expected counts: boxes and randoms
|
|
192
|
+
|
|
193
|
+
In a periodic box $\mu_i = (U - u_i)\, v_\text{region}/V$ is analytic ($U$ is the
|
|
194
|
+
total mass). In a survey it comes from the randoms,
|
|
195
|
+
$\mu_i = (U - u_i) / W_R \times$ (random weight in the region). Three refinements
|
|
196
|
+
keep the finite random catalogue from biasing the result:
|
|
197
|
+
|
|
198
|
+
* `random_correction=True`: $\mu^{-s}$ is replaced by its Poisson-unbiased estimate
|
|
199
|
+
from the random count $m$, $\alpha^{-s}\,\Gamma(m+1)/\Gamma(m+1+s)$; this is exact for
|
|
200
|
+
integer $s < 0$ and accurate to terms of order $e^{-m}$ for $s > 0$.
|
|
201
|
+
* `min_randoms=30`: a sphere, shell or wedge with fewer randoms takes its
|
|
202
|
+
expectation from the smallest sphere about the same centre with at least 30,
|
|
203
|
+
scaled by volume. This removes the random noise at small scales.
|
|
204
|
+
* `edge_cut=f`: at each radius, centres with less than a fraction $f$ of the
|
|
205
|
+
sphere inside the survey are dropped. The footprint fraction is estimated from
|
|
206
|
+
the odd-numbered randoms and the expectation from the even-numbered ones, so
|
|
207
|
+
the cut does not select on the noise of the expectation. Without an edge cut,
|
|
208
|
+
spheres that cross the survey boundary measure a truncated window, which
|
|
209
|
+
biases $D_q$ at the 0.01–0.02 level at scales where most spheres are cut.
|
|
210
|
+
|
|
211
|
+
### Minimum separation
|
|
212
|
+
|
|
213
|
+
`r_min` counts neighbours only in the shell $r_\text{min} < d \le r$, which
|
|
214
|
+
removes the smallest separations (e.g. one-halo pairs, or scales affected by
|
|
215
|
+
redshift errors or fibre collisions) from every moment; each $r_\text{min}$ must
|
|
216
|
+
be one of the radii. Only the centre–neighbour separation is limited: for
|
|
217
|
+
$q \ge 3$ the moments still involve neighbour pairs closer than $r_\text{min}$.
|
|
218
|
+
|
|
219
|
+
### Wedges and the line of sight
|
|
220
|
+
|
|
221
|
+
`wedges=n` splits each sphere into $n$ equal-width bins of $|\mu|$, the cosine of
|
|
222
|
+
the angle between the separation and the line of sight (or `wedges=[0, 0.5, 0.8, 1]`
|
|
223
|
+
for custom edges); the isotropic statistic is always returned as well. The line
|
|
224
|
+
of sight is a fixed axis in a box (`los='z'` or any vector), and in a survey the
|
|
225
|
+
direction from the `observer` to the pair midpoint (`los='midpoint'`, the default)
|
|
226
|
+
or to the centre (`los='centre'`).
|
|
227
|
+
|
|
228
|
+
### Volume-weighted
|
|
229
|
+
|
|
230
|
+
`estimator='volume'` places the centres uniformly in the volume (in a box) or on
|
|
231
|
+
the randoms (in a survey, weighted by their volume element if `nbar` is given),
|
|
232
|
+
and averages $T_q / \mu^q$ over the occupied spheres: the box-counting analogue,
|
|
233
|
+
defined for $q \ge 0$.
|
|
234
|
+
|
|
235
|
+
### Fixed mass
|
|
236
|
+
|
|
237
|
+
`fixed_mass` uses, for each centre and number $k$, the distance $r_{ik}$ of the
|
|
238
|
+
$k$-th neighbour (beyond `r_min`) and the expected number of neighbours
|
|
239
|
+
$\nu_{ik}$ within it for a homogeneous field. For Poisson sampling of any field,
|
|
240
|
+
$\nu_{ik}$ follows a Gamma($k$) distribution, whatever the geometry and selection.
|
|
241
|
+
For a measure with generalised dimensions $D_q$,
|
|
242
|
+
$\langle \nu_{ik}^{-\tau/3} \rangle \propto \Gamma(k+1-q)/\Gamma(k)$ with $\tau = (q-1) D_q$
|
|
243
|
+
(Grassberger 1985; Badii & Politi 1985; van de Water & Schram 1988), so two
|
|
244
|
+
values of $k$ determine $q(\tau)$ and $D_q = \tau / (q-1)$. A Poisson process gives
|
|
245
|
+
$D_q = 3$ at every $q$ and $k$, so the estimator has no discreteness bias, in
|
|
246
|
+
particular for $q < 1$; it needs $q < k + 1$. In a survey, $\nu$ comes from the
|
|
247
|
+
randoms, with the same random-count correction; where fewer than `min_randoms`
|
|
248
|
+
randoms lie within $r_{ik}$, the random density is taken from the distance to the
|
|
249
|
+
`min_randoms`-th random, whose enclosed expected count is also Gamma-distributed.
|
|
250
|
+
The edge cut uses the footprint fraction at one radius per $k$ (the 90th
|
|
251
|
+
percentile of $r_{ik}$), so that it does not select on each centre's own
|
|
252
|
+
neighbours.
|
|
253
|
+
|
|
254
|
+
### Jackknife
|
|
255
|
+
|
|
256
|
+
`jackknife=n` defines $n$ regions of the centres (sub-boxes in a box, where $n$ must
|
|
257
|
+
be a cube number; k-means clusters otherwise), or takes one label per centre.
|
|
258
|
+
The delete-one estimates are computed in the same pass, from per-region sums;
|
|
259
|
+
the neighbours of the remaining centres include the deleted region.
|
|
260
|
+
|
|
261
|
+
## Weights, marks and randoms
|
|
262
|
+
|
|
263
|
+
* **weights** correct the data for selection (completeness, systematics) and
|
|
264
|
+
the randoms carry the matching weights;
|
|
265
|
+
* **marks** (data only) define the measure, e.g. halo mass: each neighbour
|
|
266
|
+
contributes weight × mark, and the centres are weighted by weight × mark;
|
|
267
|
+
* **nbar** (randoms) is the expected data density at each random, which gives
|
|
268
|
+
its volume element for the edge cut and for the volume-weighted estimator.
|
|
269
|
+
|
|
270
|
+
For the fixed-radius estimators the expected mass is computed from the
|
|
271
|
+
weighted randoms, so either convention works:
|
|
272
|
+
|
|
273
|
+
1. unweighted data, and randoms that trace the observed density (including the
|
|
274
|
+
completeness, by subsampling or by weights); or
|
|
275
|
+
2. data weighted by 1/completeness, and randoms that trace the density without
|
|
276
|
+
the completeness.
|
|
277
|
+
|
|
278
|
+
The fixed-mass estimator counts neighbours, so it needs convention 1. There,
|
|
279
|
+
data weights and marks only weight the centres. A smooth mismatch between the
|
|
280
|
+
randoms and the data density multiplies each centre's expected count by a
|
|
281
|
+
factor independent of $k$, which cancels in $D_q$. A strong mismatch on the
|
|
282
|
+
scale of $r_{ik}$ does not cancel.
|
|
283
|
+
|
|
284
|
+
## Practical notes
|
|
285
|
+
|
|
286
|
+
* Integer $q \ge 2$ are exact at any occupancy (in expectation). The
|
|
287
|
+
correction for non-integer $q$ is approximate: where the spheres hold a few
|
|
288
|
+
points, non-integer orders are biased and alternate with the integer ones.
|
|
289
|
+
* $D_q$ is a scaling exponent of the measure, not the dimension of a set: for
|
|
290
|
+
$q < 0$ it can exceed 3 where the density vanishes.
|
|
291
|
+
* At the smallest radii the moments of high $q$ rest on a few centres; check
|
|
292
|
+
the jackknife errors.
|
|
293
|
+
* Use randoms with at least ~20 times the data density. The random-count
|
|
294
|
+
correction and `min_randoms` handle the small scales.
|
|
295
|
+
|
|
296
|
+
## Command line
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
pyrenyi template > box.toml # example configuration (add --survey for randoms)
|
|
300
|
+
pyrenyi run box.toml # measure, save, print a D_q table
|
|
301
|
+
pyrenyi show result.npz --errors # D_q with jackknife errors
|
|
302
|
+
pyrenyi show result.npz --r-min 10 --wedge 2 --all
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
A configuration for a survey (paths are relative to the file):
|
|
306
|
+
|
|
307
|
+
```toml
|
|
308
|
+
[data]
|
|
309
|
+
file = "galaxies.fits" # .txt/.csv, .npy, .npz, .fits, .hdf5
|
|
310
|
+
columns = ["X", "Y", "Z"] # names, or integer indices (ascii, npy)
|
|
311
|
+
weight = "WEIGHT" # a column, or a constant as a float (1.0)
|
|
312
|
+
|
|
313
|
+
[randoms]
|
|
314
|
+
file = "randoms.fits"
|
|
315
|
+
columns = ["X", "Y", "Z"]
|
|
316
|
+
nbar = "NZ" # data density at each random (for edge_cut)
|
|
317
|
+
|
|
318
|
+
[geometry]
|
|
319
|
+
observer = [0.0, 0.0, 0.0] # or: box = 1000.0 for a periodic box
|
|
320
|
+
|
|
321
|
+
[measurement]
|
|
322
|
+
estimator = "point" # "point", "volume" or "fixed-mass"
|
|
323
|
+
radii = {min = 5.0, max = 127.0, n = 15}
|
|
324
|
+
q = {min = -4.0, max = 6.0, step = 0.5}
|
|
325
|
+
r_min = [10.0] # added to a generated radii grid
|
|
326
|
+
wedges = 3
|
|
327
|
+
los = "midpoint"
|
|
328
|
+
edge_cut = 0.8
|
|
329
|
+
jackknife = 64
|
|
330
|
+
|
|
331
|
+
[output]
|
|
332
|
+
file = "dq_survey.npz"
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Unknown keys are reported with a suggestion, so typos cannot pass silently.
|
|
336
|
+
For the fixed-mass estimator, replace `radii`, `wedges` and `los` with
|
|
337
|
+
`k = {min = 1, max = 128, n = 8}`.
|
|
338
|
+
|
|
339
|
+
## Validation
|
|
340
|
+
|
|
341
|
+
The test suite (`pytest`, about two minutes) checks that:
|
|
342
|
+
|
|
343
|
+
* in a periodic box, the estimator reproduces that of Sabiu (2026) to $10^{-10}$
|
|
344
|
+
(spheres, shells, wedges, sandbox);
|
|
345
|
+
* every option (box and survey; unit weights, marks and weights; weighted
|
|
346
|
+
randoms; the three corrections; with and without the random-count
|
|
347
|
+
correction; the three lines of sight; spheres, shells and wedges; both
|
|
348
|
+
fixed-radius estimators) agrees to $10^{-10}$ with a brute-force
|
|
349
|
+
implementation;
|
|
350
|
+
* Poisson processes give $D_q = 3$:
|
|
351
|
+
* the fixed-radius estimators, for integer $q \ge 2$ at any occupancy and for
|
|
352
|
+
every $q$ once spheres hold more than ~40 points;
|
|
353
|
+
* the fixed-mass estimator, for every $q$ and $k$;
|
|
354
|
+
* both, in a survey octant with a radial selection and an edge cut;
|
|
355
|
+
* random multiplicative cascades recover their exact $D_q$ in a box and in a
|
|
356
|
+
survey;
|
|
357
|
+
* thinning by a completeness and weighting by its inverse leaves integer $q$
|
|
358
|
+
unbiased.
|
|
359
|
+
|
|
360
|
+
## Performance
|
|
361
|
+
|
|
362
|
+
Indicative times on 64 threads after compilation:
|
|
363
|
+
|
|
364
|
+
| sample | grid | time |
|
|
365
|
+
|---|---|---|
|
|
366
|
+
| 600,000 points in a box | 14 radii, 6 orders | 4 s |
|
|
367
|
+
| 30,000 points in a box | 15 radii, 21 orders, 3 minimum separations, 3 wedges | 2 s |
|
|
368
|
+
| survey: 82,000 points, 1.9 million randoms | 14 radii, 6 orders, edge cut, jackknife | 15 s |
|
|
369
|
+
| fixed mass, 600,000 points in a box | 8 values of $k$ | 4 s |
|
|
370
|
+
|
|
371
|
+
The cost grows with the number of centres times the number of points (data and
|
|
372
|
+
randoms) within the largest radius. `n_centres` subsamples the centres.
|
|
373
|
+
|
|
374
|
+
## Citing
|
|
375
|
+
|
|
376
|
+
If you use PyRenyi, please cite
|
|
377
|
+
|
|
378
|
+
* C. G. Sabiu (2026), *Cosmological Information in the Rényi Generalised
|
|
379
|
+
Dimensions of the Large-Scale Distribution of Haloes and Galaxies*, Journal
|
|
380
|
+
of the Korean Astronomical Society, submitted;
|
|
381
|
+
|
|
382
|
+
and, for the methods,
|
|
383
|
+
|
|
384
|
+
* C. G. Sabiu, L. F. A. Teodoro & M. A. Hendry (2007), *Resolving the universe
|
|
385
|
+
with multifractals*, Nuovo Cimento B 122, 1289 (arXiv:0803.3212), for the
|
|
386
|
+
point-centred (sandbox) estimator;
|
|
387
|
+
* P. Grassberger (1988), Phys. Lett. A 128, 369 and (2003),
|
|
388
|
+
arXiv:physics/0307138, for the finite-sample correction;
|
|
389
|
+
* W. van de Water & P. Schram (1988), Phys. Rev. A 37, 3118, for the
|
|
390
|
+
fixed-mass estimator.
|
|
391
|
+
|
|
392
|
+
## License
|
|
393
|
+
|
|
394
|
+
MIT; see `LICENSE`.
|