# Probability Density Estimation through Nonparametric Adaptive Partitioning and Stitching
## 2 Nonparametric Adaptive Partitioning and Stitching
### Divide and Conquer
First, we forecast the split and calculate \(R\) for the left and right blocks independently, denoted as \(R_{0}\) and \(R_{1}\), respectively. The same equations for \(R\) are used, but we calculate the quantity for subsamples that have \(n/2\) units (data points). Even when the density variation within these children subsamples are slightly greater than that for SURD, the test statistic \(\xi=(R_{0}+R_{1})/2\) will often remain less than \(An^{\epsilon}\) because the sample size of each offspring is only half as much as the parent subsample. In this way, a self-similar threshold is created by using a shift in scale. As an alternative, we tried the formula \(\xi=\max(R_{0},R_{1})\), but this created more blocks and led to inferior results overall. Intuitively, \(\xi\) represents the average density variation at the next level, which allows us to use the binary division rule given in Equation (1) to determine if a block should be split. As block sizes approach \(2w\) number of units, the blocks will stop splitting because they can no longer meet the criteria in Equation (1). This branching tree process is illustrated in Figure 3. In general the final tree that is generated can be unbalanced due to local divergent densities or heavy tails in other cases. The divide and conquer process minimizes density variation within each subsample. This strategy leads to requiring a small number of Lagrange multipliers for accurate, smooth and fast estimates within all the partitions when using NMEM. Other methods such as local regression, spline fits, or KDE could be used to estimate the PDF within blocks. For example, the blocks with simple features are more suitable for simple KDE methods. In this work, when NAPS utilizes the NMEM method, which is a C++ code, the default settings are overridden by several modifiers. The normal default parameters are set for unknown input, but now, the blocks will have much less density variation that can be taken advantage of. For all internal blocks, (1) outlier detection is turned off; (2) maximum Lagrange multipliers are capped at 100; (3) smoothing level is increased to 100; (4) confidence level for the target score is relaxed from 70% to 20%, and (5) fixed boundary conditions are used by specifying the censor window. The leftmost block uses an open boundary condition on the left with a fixed boundary on the right, while the  
Figure 3: Divide and conquer process: Partitions are generated from a sample of size \(N\) as the first partition, and then recursively divided into equal subsamples when the average density variation of offspring subsamples is above a maximum threshold. The final subsample sizes, \(n_{k}\), are shown at the final level of the unbalanced tree, with dashed red arrows pointing to distant partitions. rightmost block uses open boundary conditions on the right with a fixed boundary on the left. The results are not sensitive to the exact values for these override settings. In addition, using the MATLAB implementation, KDE with reflective boundary conditions is applied to all blocks for PDF estimates. Section 3.5 provides a comparison of the results obtained when using KDE-workers and NMEM-workers to estimate PDFs within blocks.