% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/downsample.R
\name{sample_pdf}
\alias{sample_pdf}
\title{Sample integers according to a discrete probability distribution}
\usage{
sample_pdf(
  M = 100,
  y = 2.5,
  func = function(r, M, y) exp(-r/(exp((y - 1) * (log(M)/y)))),
  n_samp = 100
)
}
\arguments{
\item{M}{Integer. Maximum value to sample (upper bound of 1:M).}

\item{y}{Numeric. Parameter controlling the distribution shape.}

\item{func}{Function. Probability function of r (1:M), M, and y.
Default is the PFWIM exponential–power law function:
\code{function(r, M, y) exp(-r / (exp((y - 1) * (log(M) / y))))}.}

\item{n_samp}{Integer. Number of random draws.}
}
\value{
Integer vector of length \code{n_samp} with values in 1:M.
}
\description{
Generates random draws from 1:M with probabilities defined by a
user-specified function (default is the PFWIM mixed exponential–power law
distribution).
}
\examples{
# Generate 3 replicate webs from a small edgelist
edgelist <- data.frame(
  res_node_node_name_inferred = c("plankton","plant_1","plant_2"),
  con_node_node_name_inferred = c("cod","rat","deer")
)
webs <- powerlaw_prey(edgelist, n_samp = 3, y = 2.5)
}
\keyword{internal}
