Stdlib module math/probability.vitl

This page is a wiki-style reference for one concrete stdlib file. It explains what the file owns, where it fits in the family, and how to decide whether this is the right surface to depend on.

Visual portrait of math/probability.vitl
Wiki-style portrait for math/probability.vitl.

Family: math

Kind: public stdlib surface

Page style: this reference follows the same “encyclopedic card + portrait + usage contract” logic as the keyword pages, but for stdlib modules.

Summary

Overview

FieldValue
Pathmath/probability.vitl
Familymath
Kindpublic stdlib surface
Line count620
Declared procedures58
Declared forms/picks0

`math/probability.vitl` is a public stdlib surface inside the `math` family. It should be read as one focused slice of the broader family responsibility: Arithmetic, algebra, comparison, calculus, geometry, modular arithmetic, number theory, probability, statistics, matrix, and vector helpers.

Purpose

This file should be chosen because of responsibility, not because its name “sounds close enough”. Inside the math family, it carries one focused part of the contract and keeps that responsibility separate from neighboring concerns.

  • A scoring engine can compute aggregates in `math` while keeping I/O and transport elsewhere.
  • A statistics or matrix chapter should explain the workflow around the computation, not just a single formula.

Taxonomy

Think of this page as a generated encyclopedia entry rather than a hand-written tutorial. The goal is to show what kind of module this is, how dense it is, and what reading strategy makes sense before depending on it.

  • Large algorithm surface: this file exposes many procedures and likely acts as a domain toolkit rather than a single thin wrapper.
  • Minimal top-level dependencies: the module reads as mostly self-contained from its opening declarations.
  • Explicit export surface: the file ends with visible export declarations instead of relying only on implicit namespace discovery.

Implementation profile

This profile is inferred directly from the source text. It does not replace reading the file, but it tells you quickly whether the module is mostly declarative, loop-heavy, branch-heavy, or organized around many small exits.

SignalCountWhat it suggests
if48Branching density and local decision-making.
while11Loop-heavy or iterative implementation style.
for0Collection-style traversal at source level.
match0Variant-driven branching or grammar-style decoding.
let65Local state and intermediate value density.
give105Number of explicit exit points and result shaping.

Top-level API inventory

SurfaceItems
Proceduresabs_int, min_int, max_int, gcd_int, valid_n_k, clamp_non_negative, factorial, double_factorial, falling_factorial, rising_factorial, permutations, arrangements
Formsnone declared at top level
Picksnone declared at top level
Constantsnone declared at top level
Exports*

Imported surfaces

This file does not advertise a top-level `use` surface in its opening declarations. That often means it is either self-contained or an aggregation layer.

Position in family

This file is module 14 of 21 in the math family when ordered by path. By procedure count it ranks 6, and by line count it ranks 8. Those ranks are useful as rough signals of breadth, not as quality judgments.

Declaration map

The declaration map turns raw source into a scan-friendly catalog. It is useful when the file is large enough that a reader wants to orient by kinds of surfaces first.

LineNameKindRole
1vitte/stdlib/math/probabilityspaceDeclares the namespace that anchors this file in the stdlib tree.
11abs_intprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
19min_intprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
27max_intprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
35gcd_intprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
48valid_n_kprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
52clamp_non_negativeprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
64factorialprocImplements a counting or probability helper inside the math boundary.
84double_factorialprocImplements a counting or probability helper inside the math boundary.
104falling_factorialprocImplements a counting or probability helper inside the math boundary.
125rising_factorialprocImplements a counting or probability helper inside the math boundary.
150permutationsprocImplements a counting or probability helper inside the math boundary.
154arrangementsprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
158permutations_with_repetitionprocImplements a counting or probability helper inside the math boundary.
182combinationsprocImplements a counting or probability helper inside the math boundary.
221chooseprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
225combinations_with_repetitionprocImplements a counting or probability helper inside the math boundary.
242multiset_combinationsprocImplements a counting or probability helper inside the math boundary.
250pairingsprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
259unordered_pairsprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
263ordered_pairsprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
272derangementsprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
305ratio_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
313percentage_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
321probabilityprocImplements a counting or probability helper inside the math boundary.
325probability_percentprocImplements a counting or probability helper inside the math boundary.
333probability_percent_f64procImplements a counting or probability helper inside the math boundary.
337permille_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
345basis_points_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
353complement_probabilityprocImplements a counting or probability helper inside the math boundary.
362complement_percentprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
371success_rate_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
375failure_rate_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
384success_rate_percentprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
388failure_rate_percentprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
401odds_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
409odds_percentprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
417odds_ratioprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
421odds_ratio_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
425success_failure_ratio_percentprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
429relative_risk_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
440odds_ratio_2x2procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
454favorable_probabilityprocImplements a counting or probability helper inside the math boundary.
458equally_likely_probabilityprocImplements a counting or probability helper inside the math boundary.
462union_probability_disjointprocImplements a counting or probability helper inside the math boundary.
466union_probabilityprocImplements a counting or probability helper inside the math boundary.
470intersection_independentprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
474complement_from_probabilityprocImplements a counting or probability helper inside the math boundary.
478conditional_probabilityprocImplements a counting or probability helper inside the math boundary.
486expected_value_binaryprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
497binomial_pmfprocImplements a counting or probability helper inside the math boundary.
526geometric_pmfprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
547hypergeometric_pmfprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
583percentprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
587percent_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
591choose_probabilityprocImplements a counting or probability helper inside the math boundary.
595probability_versionprocImplements a counting or probability helper inside the math boundary.
599probability_readyprocImplements a counting or probability helper inside the math boundary.
603probability_selftestprocImplements a counting or probability helper inside the math boundary.

The table is exhaustive for top-level declarations of the selected kinds. This file declares 59 matching surfaces.

Representative signatures

These signatures are shown in source order so the page keeps the feel of a reference manual, not just a keyword cloud.

  • proc abs_int(value: int) -> int { (line 11)
  • proc min_int(a: int, b: int) -> int { (line 19)
  • proc max_int(a: int, b: int) -> int { (line 27)
  • proc gcd_int(a: int, b: int) -> int { (line 35)
  • proc valid_n_k(n: int, k: int) -> bool { (line 48)
  • proc clamp_non_negative(value: int) -> int { (line 52)
  • proc factorial(value: int) -> int { (line 64)
  • proc double_factorial(value: int) -> int { (line 84)
  • proc falling_factorial(n: int, k: int) -> int { (line 104)
  • proc rising_factorial(n: int, k: int) -> int { (line 125)
  • proc permutations(n: int, k: int) -> int { (line 150)
  • proc arrangements(n: int, k: int) -> int { (line 154)
  • proc permutations_with_repetition(n: int, k: int) -> int { (line 158)
  • proc combinations(n: int, k: int) -> int { (line 182)
  • proc choose(n: int, k: int) -> int { (line 221)
  • proc combinations_with_repetition(n: int, k: int) -> int { (line 225)
  • proc multiset_combinations(n: int, k: int) -> int { (line 242)
  • proc pairings(total: int) -> int { (line 250)

The list is intentionally capped here; the source file declares 58 matching signatures in total.

How to use this module

Start by reading the file as an ownership boundary. Ask three questions: what enters this module, what stable types or procedures it exports, and what adjacent module should stay outside of it.

  1. Read space and top-level imports first so the ownership boundary of math/probability.vitl is explicit.
  2. Traverse procedures in source order; the early helpers usually explain the naming and numeric conventions used later.
  3. Use the source landmarks section below as a table of contents when the file is large.
  4. Only after that compare neighbor modules, because the right boundary choice matters more than memorizing one helper name.

User example

This example is generated from the actual stdlib module surface. Its job is not to be the smallest snippet possible; its job is to show a realistic consumer-shaped file that exercises the module and mirrors the language keywords the module itself relies on.

space demo/math_probability
proc run_example() -> string {
  let result = abs_int(1)
  let ready: bool = valid_n_k(1, 1)
  let stable: bool = ready and true
  let fallback: bool = ready or false
  let idx: int = 0
  while idx < 1 {
    set idx = idx + 1
  }
  if not ready {
    give "not-ready"
  } else {
    give "ok"
  }
  let copies: f64 = 1 as f64
}
export run_example

Keyword coverage

This table makes the “all keywords of the module” requirement auditable. It compares the detected Vitte keywords in the source file with the generated consumer example above.

KeywordPresent in module sourceUsed in generated user example
spaceyesyes
procyesyes
letyesyes
setyesyes
ifyesyes
elseyesyes
whileyesyes
giveyesyes
exportyesyes
trueyesyes
andyesyes
oryesyes
notyesyes
asyesyes

The generated snippet exercises every detected Vitte keyword used by this module.

Source shape

space vitte/stdlib/math/probability
proc abs_int(value: int) -> int {
  if value < 0 {
    give -value
  } else {
    give value
  }
}
proc min_int(a: int, b: int) -> int {
  if a < b {

The excerpt is not meant to replace the file. It exists to make the module recognizable at first glance, the same way a Wikipedia infobox helps the reader orient before reading the whole article.

Source landmarks

Large files are easier to retain when they have visible landmarks. When the source contains explicit section banners, they are surfaced here; otherwise the first major declarations are used as anchors.

  • Probability / combinatorics — ultra complete module
  • Internal helpers
  • Factorial family
  • Permutations / arrangements
  • Combinations
  • Pairings / simple counts
  • Ratios / percentages
  • Odds / ratios
  • Discrete probability helpers
  • Classical discrete distributions

Source organization

When a file carries its own internal chaptering, those chapters usually reveal the intended reading order better than a flat symbol list. This section reconstructs that organization from the source itself.

Opening declarations

Top-level items: 1. Procedures: 0. Data surfaces: 0. Constants: 0.

First visible names: vitte/stdlib/math/probability

Internal helpers

Top-level items: 6. Procedures: 6. Data surfaces: 0. Constants: 0.

First visible names: abs_int, min_int, max_int, gcd_int, valid_n_k, clamp_non_negative

Factorial family

Top-level items: 4. Procedures: 4. Data surfaces: 0. Constants: 0.

First visible names: factorial, double_factorial, falling_factorial, rising_factorial

Permutations / arrangements

Top-level items: 3. Procedures: 3. Data surfaces: 0. Constants: 0.

First visible names: permutations, arrangements, permutations_with_repetition

Combinations

Top-level items: 4. Procedures: 4. Data surfaces: 0. Constants: 0.

First visible names: combinations, choose, combinations_with_repetition, multiset_combinations

Pairings / simple counts

Top-level items: 4. Procedures: 4. Data surfaces: 0. Constants: 0.

First visible names: pairings, unordered_pairs, ordered_pairs, derangements

Ratios / percentages

Top-level items: 13. Procedures: 13. Data surfaces: 0. Constants: 0.

First visible names: ratio_f64, percentage_f64, probability, probability_percent, probability_percent_f64, permille_f64, basis_points_f64, complement_probability, complement_percent, success_rate_f64

Odds / ratios

Top-level items: 7. Procedures: 7. Data surfaces: 0. Constants: 0.

First visible names: odds_f64, odds_percent, odds_ratio, odds_ratio_f64, success_failure_ratio_percent, relative_risk_f64, odds_ratio_2x2

Discrete probability helpers

Top-level items: 8. Procedures: 8. Data surfaces: 0. Constants: 0.

First visible names: favorable_probability, equally_likely_probability, union_probability_disjoint, union_probability, intersection_independent, complement_from_probability, conditional_probability, expected_value_binary

Classical discrete distributions

Top-level items: 3. Procedures: 3. Data surfaces: 0. Constants: 0.

First visible names: binomial_pmf, geometric_pmf, hypergeometric_pmf

Convenience aliases

Top-level items: 7. Procedures: 6. Data surfaces: 0. Constants: 0.

First visible names: percent, percent_f64, choose_probability, probability_version, probability_ready, probability_selftest, *

Complete API catalog

This catalog is the exhaustive file-level index for the module. It is intentionally closer to a generated encyclopedia appendix than to a tutorial summary.

Procedures

LineNameSignatureRole
11abs_intproc abs_int(value: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
19min_intproc min_int(a: int, b: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
27max_intproc max_int(a: int, b: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
35gcd_intproc gcd_int(a: int, b: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
48valid_n_kproc valid_n_k(n: int, k: int) -> bool {Represents one top-level surface in the file contract and should be read as part of the module boundary.
52clamp_non_negativeproc clamp_non_negative(value: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
64factorialproc factorial(value: int) -> int {Implements a counting or probability helper inside the math boundary.
84double_factorialproc double_factorial(value: int) -> int {Implements a counting or probability helper inside the math boundary.
104falling_factorialproc falling_factorial(n: int, k: int) -> int {Implements a counting or probability helper inside the math boundary.
125rising_factorialproc rising_factorial(n: int, k: int) -> int {Implements a counting or probability helper inside the math boundary.
150permutationsproc permutations(n: int, k: int) -> int {Implements a counting or probability helper inside the math boundary.
154arrangementsproc arrangements(n: int, k: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
158permutations_with_repetitionproc permutations_with_repetition(n: int, k: int) -> int {Implements a counting or probability helper inside the math boundary.
182combinationsproc combinations(n: int, k: int) -> int {Implements a counting or probability helper inside the math boundary.
221chooseproc choose(n: int, k: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
225combinations_with_repetitionproc combinations_with_repetition(n: int, k: int) -> int {Implements a counting or probability helper inside the math boundary.
242multiset_combinationsproc multiset_combinations(n: int, k: int) -> int {Implements a counting or probability helper inside the math boundary.
250pairingsproc pairings(total: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
259unordered_pairsproc unordered_pairs(total: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
263ordered_pairsproc ordered_pairs(total: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
272derangementsproc derangements(n: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
305ratio_f64proc ratio_f64(part: int, total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
313percentage_f64proc percentage_f64(part: int, total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
321probabilityproc probability(part: int, total: int) -> f64 {Implements a counting or probability helper inside the math boundary.
325probability_percentproc probability_percent(part: int, total: int) -> int {Implements a counting or probability helper inside the math boundary.
333probability_percent_f64proc probability_percent_f64(part: int, total: int) -> f64 {Implements a counting or probability helper inside the math boundary.
337permille_f64proc permille_f64(part: int, total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
345basis_points_f64proc basis_points_f64(part: int, total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
353complement_probabilityproc complement_probability(part: int, total: int) -> f64 {Implements a counting or probability helper inside the math boundary.
362complement_percentproc complement_percent(part: int, total: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
371success_rate_f64proc success_rate_f64(successes: int, total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
375failure_rate_f64proc failure_rate_f64(successes: int, total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
384success_rate_percentproc success_rate_percent(successes: int, total: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
388failure_rate_percentproc failure_rate_percent(successes: int, total: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
401odds_f64proc odds_f64(successes: int, failures: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
409odds_percentproc odds_percent(successes: int, failures: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
417odds_ratioproc odds_ratio(successes: int, failures: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
421odds_ratio_f64proc odds_ratio_f64(successes: int, failures: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
425success_failure_ratio_percentproc success_failure_ratio_percent(successes: int, failures: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
429relative_risk_f64proc relative_risk_f64(exposed_successes: int, exposed_total: int, control_successes: int, control_total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
440odds_ratio_2x2proc odds_ratio_2x2(a: int, b: int, c: int, d: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
454favorable_probabilityproc favorable_probability(favorable: int, total: int) -> f64 {Implements a counting or probability helper inside the math boundary.
458equally_likely_probabilityproc equally_likely_probability(favorable: int, possible: int) -> f64 {Implements a counting or probability helper inside the math boundary.
462union_probability_disjointproc union_probability_disjoint(p_a: f64, p_b: f64) -> f64 {Implements a counting or probability helper inside the math boundary.
466union_probabilityproc union_probability(p_a: f64, p_b: f64, p_intersection: f64) -> f64 {Implements a counting or probability helper inside the math boundary.
470intersection_independentproc intersection_independent(p_a: f64, p_b: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
474complement_from_probabilityproc complement_from_probability(p: f64) -> f64 {Implements a counting or probability helper inside the math boundary.
478conditional_probabilityproc conditional_probability(intersection: f64, given_event: f64) -> f64 {Implements a counting or probability helper inside the math boundary.
486expected_value_binaryproc expected_value_binary(success_probability: f64, success_value: f64, failure_value: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
497binomial_pmfproc binomial_pmf(trials: int, successes: int, p: f64) -> f64 {Implements a counting or probability helper inside the math boundary.
526geometric_pmfproc geometric_pmf(trial_index: int, p: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
547hypergeometric_pmfproc hypergeometric_pmf(population: int, success_population: int, draws: int, observed_successes: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
583percentproc percent(part: int, total: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
587percent_f64proc percent_f64(part: int, total: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
591choose_probabilityproc choose_probability(favorable: int, total: int) -> f64 {Implements a counting or probability helper inside the math boundary.
595probability_versionproc probability_version() -> string {Implements a counting or probability helper inside the math boundary.
599probability_readyproc probability_ready() -> bool {Implements a counting or probability helper inside the math boundary.
603probability_selftestproc probability_selftest() -> bool {Implements a counting or probability helper inside the math boundary.

Exports

LineNameSignatureRole
620*export *Re-exports surfaces that the module wants to expose as part of its public boundary.

Integration boundaries

Within math, this file should remain focused. If a future helper changes the host boundary, scheduling boundary, or data-shape boundary, it probably belongs in a neighbor module instead of being added here by convenience.

  • Family responsibility: Arithmetic, algebra, comparison, calculus, geometry, modular arithmetic, number theory, probability, statistics, matrix, and vector helpers.
  • Family architecture role: Use `math` when the transformation itself is the feature. This family exists so algorithmic intent stays visible and testable.

Composition guidance

Choose this module when

  • Choose math/probability.vitl when the main question is owned by this module rather than by transport, storage, orchestration, or user-interface code.
  • A scoring engine can compute aggregates in `math` while keeping I/O and transport elsewhere.
  • A statistics or matrix chapter should explain the workflow around the computation, not just a single formula.

Pause before extending it when

  • Avoid extending this file when the new helper mostly changes the boundary to host I/O, runtime coordination, or foreign integration instead of staying inside math.
  • Check nearby modules such as math/algebra.vitl, math/arithmetic.vitl, math/arrays.vitl before adding convenience wrappers here.

Relationship table

This table keeps the page closer to a real encyclopedia entry: a module is easier to understand when compared with its nearest alternatives in the same family.

NeighborProceduresData surfacesWhy compare it
math/algebra.vitl140Shares the same family boundary but carries a distinct slice of responsibility.
math/arithmetic.vitl722Shares the same family boundary but carries a distinct slice of responsibility.
math/arrays.vitl832Shares the same family boundary but carries a distinct slice of responsibility.
math/calculus.vitl563Shares the same family boundary but carries a distinct slice of responsibility.
math/comparison.vitl470Shares the same family boundary but carries a distinct slice of responsibility.
math/complex.vitl490Shares the same family boundary but carries a distinct slice of responsibility.
math/geometry.vitl720Shares the same family boundary but carries a distinct slice of responsibility.
math/logic.vitl200Shares the same family boundary but carries a distinct slice of responsibility.

Neighbor modules