CalcTree Help Pages
  • What is CalcTree?
  • Getting started
    • CalcTree Pages
    • Create a CalcTree Page
    • Add a calculation
    • Collaborate with a colleague
  • Calculations
    • Parameters
      • Math formulas
        • Parameter Data Types
        • Native Functions
          • Arithmetic Functions
          • Trigonometric Functions
          • Logical & Comparison Functions
          • Matrix & Vector Functions
          • Probability & Combinatorics Functions
          • Statistical Functions
          • String Functions
          • Utility Functions
          • Other Native Functions
        • Valid Expression Syntax
      • Supported Units
      • Dropdown List Parameters
        • Linking CSV Data to Dependent Dropdowns in CalcTree
      • Parameter Settings
    • Integrations
      • Python in CalcTree
        • Adding a Python Source
        • Defining Parameters in Python
        • Referencing Other Parameters in Python
        • Working with Units in Python
        • Creating Tables and Visuals in Python
        • Consuming Files in Python
        • Using Pre-installed Python Libraries
      • Spreadsheets [Coming Soon!]
      • File Upload
        • CSV files
      • 3rd Party Software Plugins
        • Excel
        • Grasshopper
        • ETABS [v20 & v21]
        • ETABS [v22]
        • SAP 2000
        • CSI Bridge [v26]
    • Templates [Coming Soon!]
    • Optimising your calculations
  • Pages & Reports
    • CalcTree Documents
    • Static content
    • Parametric content
      • Parametric equation
      • Inputs
      • Outputs
  • Export to PDF
  • API
    • GraphQL API
      • Generating an API key
      • Queries
        • GetCalculation
        • Calculate
      • Examples
        • Bulk calculations with Python
  • Collaborate
    • Add members
    • Review and approval
    • Add stakeholders
  • Administrate
    • CalcTree Workspace
    • Versioning and Audit trail
  • CalcTree for System Administrators
Powered by GitBook
On this page
  • Combinatorics Functions
  • Probability Functions
  • Notes for CalcTree
  1. Calculations
  2. Parameters
  3. Math formulas
  4. Native Functions

Probability & Combinatorics Functions

PreviousMatrix & Vector FunctionsNextStatistical Functions

Last updated 1 day ago

CalcTree includes built-in support for common statistical counting functions and probability-related tools via . These functions help with uncertainty analysis, risk assessment, and combinatorial calculations.

Combinatorics Functions

These functions return counts of arrangements, selections, and partitions.

Function
Description
CalcTree Example

factorial(n)

n! — factorial of a number

factorial(5) → 120

combinations(n, k)

Ways to choose k unordered items from n (no repetition)

combinations(5, 2) → 10

combinationsWithRep(n, k)

Choose k unordered items with repetition

combinationsWithRep(3, 2) → 6

permutations(n [, k])

Ordered subsets of length k (default is n!)

permutations(4, 2) → 12

multinomial([a1, a2, …])

Ways to divide a set into subgroups of given sizes

multinomial([2, 1]) → 3

bellNumbers(n)

Count of set partitions

bellNumbers(3) → 5

catalan(n)

Number of valid bracketings, rooted trees, etc.

catalan(3) → 5

composition(n, k)

Ways to write n as a sum of k positive integers

composition(5, 2) → 4

stirlingS2(n, k)

Stirling numbers of the second kind — set partitions

stirlingS2(4, 2) → 7

Probability Functions

These functions support basic probability distributions and randomness.

Function
Description
CalcTree Example

gamma(n)

Gamma function (generalization of factorial)

gamma(6) → 120

lgamma(n)

Logarithm of gamma function

lgamma(6) → ~4.787...

kldivergence(x, y)

Kullback-Leibler divergence between two distributions

kldivergence([0.4, 0.6], [0.5, 0.5])

random()

Random number between 0 and 1 (uniform)

random() → varies

random(min, max)

Random number in given range

random(10, 20) → varies

randomInt(min, max)

Random integer in range

randomInt(1, 6) → like a dice roll

pickRandom(arr)

Randomly select one or more values from a list

pickRandom([1, 2, 3]) → 2

Notes for CalcTree

  • You can use random() in param formulas, but values will refresh on each evaluation.

  • Combinatoric functions return exact values, useful for reliability and arrangement modeling.

  • Use gamma(n + 1) as an alternative to factorial(n) for non-integers.

📘 Looking for more functions? CalcTree’s expression engine is powered by . For a full list of available functions, visit the . Most functions listed there are supported in CalcTree unless otherwise noted.

MathJS
MathJS
MathJS Function Reference