Skip to content

Math Formulas in LaTeX, Python, and R


Contributors:
Pretty Image
Erica Madebeykin
PGDip Researcher
Pretty Image
Nikita Madebeykin
ML Engineer
Creation Date:
October 20, 2024

Copy and Paste the Mathematical Formulas in LaTeX, Python and R

Useful Code snippets for Math Notations and Formulas.

Just click the upper right corner button!

1. Mean Formula

Notation

x¯=i=1nxin

LaTeX code snippet for Mean formula

markdown
$$
\bar{x} = \frac{\sum_{i=1}^{n} x_i}{n}
$$

Reusable Python code snippet for Mean formula

Python
from typing import List
def mean(values: List[float]):
    sum = 0.0
    for value in values:
        sum += value
    return sum / len(values)

# should print 0.0
print(mean([-2, 2]))

# should print 7.0
print(mean([3, 6, 12]))

R code snippet for Mean formula

R
# R code snippet for Mean
kitty_data <- c(1, 2, 3, 4, 5)
x_bar <- mean(kitty_data)
print(x_bar)

✅Summarized reviews based on Kittycat's insights from the best online courses at top universities