# Entropy and Testing with np

This vignette is meant to be a small package-side introduction to the entropy-based testing tools in `np`. It is intentionally much shorter than the legacy article-style document and focuses on what the functions are for and one small runnable example.

The fuller narrative treatment now belongs on the gallery site rather than in a shipped package vignette:

- https://jeffreyracine.github.io/gallery/entropy_tests.html

## Main functions

The main entropy-based testing functions are:

- `npdeneqtest`: equality of multivariate densities
- `npunitest`: equality of univariate densities
- `npsymtest`: asymmetry in a univariate variable or series
- `npdeptest`: nonlinear pairwise dependence
- `npsdeptest`: nonlinear serial dependence

These functions can be computationally demanding, especially when integration and bootstrap resampling are involved.

## A small example

For a first run, it is reasonable to begin with a simple univariate comparison and keep the example small enough that bootstrapping remains practical.

    library(np)
    #> np 0.70-5
    #> Examples and guides at https://jeffreyracine.github.io/gallery/
    #> See also vignette("np_getting_started", package = "np")
    set.seed(42)

    n <- 250
    x <- rnorm(n)
    y <- rnorm(n)

    npunitest(x, y, bootstrap = TRUE)
    #>
    #> Consistent Univariate Entropy Density Equality Test
    #> 399 Bootstrap Replications
    #>
    #> Test Statistic 'Srho': 0.001213156   P Value: 0.98997
    #> ---
    #> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    #> Fail to reject the null of equality at the 10% level

## Practical guidance

- start with the smallest example that answers your question,
- use the default integral-based versions for serious work unless you have a reason not to,
- expect runtime to grow quickly when bootstrap resampling is involved,
- if the testing workflow is correct but the runtime becomes burdensome, move to `npRmpi` rather than rewriting the statistical problem.

## Where to go next

- `?npunitest`, `?npdeneqtest`, `?npdeptest`, `?npsdeptest`, `?npsymtest`
- https://jeffreyracine.github.io/gallery/entropy_tests.html for the longer website article
- https://jeffreyracine.github.io/gallery/mpi_large_data.html if the testing workflow is correct but runtime now points to `npRmpi`