Skip to contents

R arm of the Python modules of the Morin shelf (morie.fn.at_least_one_of_iid, bayes_general, sd_of_mean, ...): counting (factorial, stars and bars, card-hand suit patterns), the rules of probability (chain rule, or rules, inclusion-exclusion, Bayes), independence of joint pmfs and densities, moments of pmfs and their scaling and sums, standard deviations of means, the exponential waiting-time density and the correlation results of chapter 6 (regression slope, prediction improvement, regression to the mean). Each returns the Python result's payload as a list.

Usage

AtLeastOneOfIid(p, k = 3)

AtMostTwoSuitsProbability(n_suits = 4, n_ranks = 13, hand = 5)

BayesGeneral(priors, likelihoods)

BayesSimple(p_z_given_a, p_a, p_z)

ChainRule(p_a, p_b_given_a, p_b, p_a_given_b)

EXSquared(sigma, mu)

ExactHalfHeads(n)

ExcessScoreFactor(r)

ExpectationLinear(a, e_x, b, e_y, c)

ExponentialCrossingTime(rate_fast = 0.2, rate_slow = 0.05, ratio = 4)

ExponentialWaitingDensity(t, lam)

MorinFactorial(n)

InclusionExclusion3(p_a, p_b, p_c, p_ab, p_ac, p_bc, p_abc)

JointDensityFactorizes(grid_x, density_x, grid_y, density_y)

JointIndependent(joint, tol = 1e-09)

PmfSd(values, probs)

PmfSumConvolution(values_x, probs_x, values_y, probs_y)

PredictionImprovement(r)

ProbOrExclusive(ps)

ProbOrGeneral(p_a, p_b, p_ab)

RegressionToMeanFactor(r, y1)

SdBernoulli(p)

SdFairCoinAvg(n)

SdOfMean(sigma, n)

SdOfMeanHetero(sigmas)

SdScale(a, sigma)

SlopeFromCov(x, y)

StarsAndBars(n, N)

SuitFullHouseProbability(n_suits = 4, n_ranks = 13, k_major = 3, k_minor = 2)

VarScale(a, var_x)

VarSumWithCov(var_x, var_y, cov_xy = 0)

Arguments

p, k

Event probability and number of independent trials.

n_suits, n_ranks, hand, k_major, k_minor

Deck and hand sizes.

priors, likelihoods

Prior and likelihood vectors.

p_z_given_a, p_a, p_z

Terms of the simple Bayes formula.

p_b_given_a, p_b, p_a_given_b

Terms of the chain rule.

sigma, mu

Standard deviation and mean.

n

Integer size.

r

Correlation coefficient.

a, e_x, b, e_y, c

Coefficients and expectations.

rate_fast, rate_slow, ratio

Exponential rates and ratio.

t, lam

Time and rate.

p_c, p_ab, p_ac, p_bc, p_abc

Event and intersection probabilities.

grid_x, density_x, grid_y, density_y

Density grids.

joint

Joint pmf table.

tol

Tolerance.

values, probs

Pmf support and probabilities.

values_x, probs_x, values_y, probs_y

Two pmfs.

ps

Probabilities of exclusive events.

y1

First-test score deviation.

sigmas

Standard deviations.

x, y

Data vectors.

N

Number of categories.

var_x, var_y, cov_xy

Variances and covariance.

Value

A named list (the Python payload).

References

Morin, D. J. (2016). Probability: For the Enthusiastic Beginner. Createspace Independent Publishing, chapters 1-6.

Examples

AtLeastOneOfIid(1 / 6, 3)$p_at_least_one
#> [1] 0.4212963
BayesGeneral(c(0.5, 0.3, 0.2), c(0.1, 0.4, 0.8))$posteriors
#> [1] 0.1515152 0.3636364 0.4848485
StarsAndBars(3, 4)$count
#> [1] 20