Assess how often a specified number of independent structures would face a target by chance, given the chance for one structure.
bernoulli.trial(n, p, r, type = "tail")
n |
Total number of structures: a single finite nonnegative integer. |
p |
Target probability: a single finite number between 0 and 1. |
r |
Number of hits: a single finite integer between 0 and n. |
type |
Either |
Define a hit and the per-structure chance of a hit before counting the orientations. A single-count probability answers how often exactly that count arises; the upper tail answers how often a count at least that large arises.
The binomial model assumes independent structures with the same
target probability p. The upper-tail probability is a one-sided
p-value under this model. Calculations use stats::dbinom and
stats::pbinom, avoiding factorial overflow and subtraction from 1.
At least zero hits has probability 1. With zero structures, zero hits has
probability 1 for either type. Inputs are scalar; invalid inputs error.
A numeric probability between 0 and 1.
Exact and upper-tail probabilities agreed with independent binomial calculations for the tested counts up to 1,000, including zero hits. See S03 validation in the technical manual.
The fixed uniform-null example returned a global probability of 0.4375 and an adjusted probability of 0.1875 for its cluster crossing north. S03 study.
Ruggles, C (1999) Astronomy in Prehistoric Britain and Ireland. Yale University Press.
randomTest, modelTest
# At least 10 out of 30 structures, with targets covering 20% of the horizon:
bernoulli.trial(30, 0.2, 10)
# Exactly 10 hits:
bernoulli.trial(30, 0.2, 10, type="single")
bernoulli.trial(30, 0.2, 0) # Always 1
bernoulli.trial(1000, 0.2, 250) # No factorial overflow