npairs_jackknife_3d¶

halotools.mock_observables.pair_counters.
npairs_jackknife_3d
(sample1, sample2, rbins, jtags1, jtags2, N_samples, period=None, weights1=None, weights2=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source] [edit on github]¶ Pair counter used to make jackknife error estimates of realspace pair counter
npairs
.Parameters:  sample1 : array_like
Numpy array of shape (Npts1, 3) containing 3D positions of points. See the Formatting your xyz coordinates for Mock Observables calculations documentation page, or the Examples section below, for instructions on how to transform your coordinate position arrays into the format accepted by the
sample1
andsample2
arguments. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. sample2 : array_like, optional
Numpy array of shape (Npts2, 3) containing 3D positions of points. Should be identical to sample1 for cases of autosample pair counts. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
 rbins : array_like
Boundaries defining the bins in which pairs are counted. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.
 jtags1 : array_like
Numpy array of shape (Npts1, ) containing integer tags used to define jackknife sample membership. Tags are in the range [1, N_samples]. The tag ‘0’ is a reserved tag and should not be used.
 jtags2 : array_like
Numpy array of shape (Npts2, ) containing integer tags used to define jackknife sample membership. Tags are in the range [1, N_samples]. The tag ‘0’ is a reserved tag and should not be used.
 N_samples : int
Total number of jackknife samples. All values of
jtags1
andjtags2
should be in the range [1, N_samples]. period : array_like, optional
Length3 sequence defining the periodic boundary conditions in each dimension. If you instead provide a single scalar, Lbox, period is assumed to be the same in all Cartesian directions.
 weights1 : array_like, optional
Numpy array of shape (Npts1, ) containing weights used for weighted pair counts.
 weights2 : array_like, optional
Numpy array of shape (Npts2, ) containing weights used for weighted pair counts.
 num_threads : int, optional
Number of threads to use in calculation, where parallelization is performed using the python
multiprocessing
module. Default is 1 for a purely serial calculation, in which case a multiprocessing Pool object will never be instantiated. A string ‘max’ may be used to indicate that the pair counters should use all available cores on the machine. approx_cell1_size : array_like, optional
Length3 array serving as a guess for the optimal manner by how points will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, which will return reasonable result performance for most usecases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performancecritical calculations.
 approx_cell2_size : array_like, optional
Analogous to
approx_cell1_size
, but for sample2. See comments forapprox_cell1_size
for details.
Returns:  N_pairs : array_like
Numpy array of shape (N_samples+1,len(rbins)). The subarray N_pairs[0, :] stores numbers of pairs in the input bins for the entire sample. The subarray N_pairs[i, :] stores numbers of pairs in the input bins for the \(i^{\rm th}\) jackknife subsample.
Notes
Jackknife weights are calculated using a weighting function.
If both points are outside the sample, the weighting function returns 0. If both points are inside the sample, the weighting function returns (w1 * w2) If one point is inside, and the other is outside, the weighting function returns (w1 * w2)/2
Examples
For demonstration purposes we create randomly distributed sets of points within a periodic unit cube.
>>> from halotools.mock_observables.pair_counters import npairs_jackknife_3d >>> Npts1, Npts2, Lbox = 1000, 1000, 250. >>> period = [Lbox, Lbox, Lbox] >>> rbins = np.logspace(1, 1.5, 15)
>>> x1 = np.random.uniform(0, Lbox, Npts1) >>> y1 = np.random.uniform(0, Lbox, Npts1) >>> z1 = np.random.uniform(0, Lbox, Npts1) >>> x2 = np.random.uniform(0, Lbox, Npts2) >>> y2 = np.random.uniform(0, Lbox, Npts2) >>> z2 = np.random.uniform(0, Lbox, Npts2)
We transform our x, y, z points into the array shape used by the paircounter by taking the transpose of the result of
numpy.vstack
. This boilerplate transformation is used throughout themock_observables
subpackage:>>> sample1 = np.vstack([x1, y1, z1]).T >>> sample2 = np.vstack([x2, y2, z2]).T
Ordinarily, you would create
jtags
for the points by properly subdivide the points into spatial subvolumes. For illustration purposes, we’ll simply use randomly assigned subvolumes as this has no impact on the calling signature:>>> N_samples = 10 >>> jtags1 = np.random.randint(1, N_samples+1, Npts1) >>> jtags2 = np.random.randint(1, N_samples+1, Npts2)
>>> result = npairs_jackknife_3d(sample1, sample2, rbins, period = period, jtags1=jtags1, jtags2=jtags2, N_samples = N_samples)