\HeaderA{Pval.dist}{p-value of a given similarity value}{Pval.dist}
\keyword{misc}{Pval.dist}
\begin{Description}\relax
This function calculates the p-value of a given similarity value,
i.e. the probability for obtaining the same or a smaller value than
the given one in a vector of random similarity values. The p-value is
used to determine whether the given similarity value is significant.
\end{Description}
\begin{Usage}
\begin{verbatim}
Pval.dist(dist.val, random.vals)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{dist.val}] A \code{numeric} value quanifying the similarity
for which a p-value should be calculated. 
\item[\code{random.vals}] A \code{numeric} vector of random similarities used
for calculating the p-value.
\end{ldescription}
\end{Arguments}
\begin{Value}
It returns a \code{numeric} value between 0 and 1 that specifies the
p-value of the given \code{dist.val}.
\end{Value}
\begin{Author}\relax
Jasmina Bogojeska
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{L1.dist}{L1.dist}}, \code{\LinkA{kullback.leibler}{kullback.leibler},
    \bsl{}code\{\LinkA{kullback.leibler}{kullback.leibler}\}, \bsl{}code\{\LinkA{kullback.leibler}{kullback.leibler}\}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## The function is currently defined as
function(dist.val, random.vals) {
  return((sum(random.vals <= dist.val) + 1) /(length(random.vals) + 1))
  }

## Define the similarity value and a vector of random similarities
sim.val <- 0.2
rand.vals <- c(0.1, 0.24, 0.28, 0.35, 0.15, 0.5, 0.14, 0.6, 0.8, 0.3)

## Calculate the p-value of sim.val using the vector of random
## similarities
Pval.dist(dist.val = sim.val, random.vals = rand.vals)
 
\end{ExampleCode}
\end{Examples}

