# PetscProbComputeKSStatistic
Compute the Kolmogorov-Smirnov statistic for the empirical distribution for an input vector, compared to an analytic CDF. 
## Synopsis
```
#include "petscdt.h" 
PetscErrorCode PetscProbComputeKSStatistic(Vec v, PetscProbFunc cdf, PetscReal *alpha)
```
Collective on v


## Input Parameters

- ***v   -*** The data vector, blocksize is the sample dimension
- ***cdf -*** The analytic CDF



## Output Parameter

- ***alpha -*** The KS statisic





## Notes
The Kolmogorov-Smirnov statistic for a given cumulative distribution function $F(x)$ is
```none
    D_n = \sup_x \left| F_n(x) - F(x) \right|

  where $\sup_x$ is the supremum of the set of distances, and the empirical distribution function $F_n(x)$ is discrete, and given by

    F_n =  # of samples <= x / n
```


The empirical distribution function $F_n(x)$ is discrete, and thus had a ``stairstep''
cumulative distribution, making $n$ the number of stairs. Intuitively, the statistic takes
the largest absolute difference between the two distribution functions across all $x$ values.


## See Also
 `PetscProbFunc`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/dt/interface/dtprob.c.html#PetscProbComputeKSStatistic">src/dm/dt/interface/dtprob.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/dt/interface/dtprob.c)


[Index of all DT routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
