Continue reading

# Tag Archives: python

# Areas of Quadrilaterals with Bretschneider’s Formula in Python

In this article I will demonstrate how to calculate the area of any quadrilateral, or four-sided figure, in Python using Bretschneider's Formula.

Continue reading# Calculating Areas of Quadrilaterals in Python

This is the first in a set of three articles describing how to calculate the areas of various types of quadrilaterals using the Python programming language.

Continue reading# Geometric and Harmonic Means in Python

The most commonly known and used statistical mean is the arithmetic mean, calculated by adding all values and dividing the result by the number of values. The arithmetic mean is one of a "family" of three means called the Pythagorean means, the other two being the geometric mean and the harmonic mean. In this post I will explain when you might need to use these alternatives and then show how to calculate them using Python.

Continue reading# The Fundamentals of Bayes’ Theorem in Python

# Trigonometry in Python

Python's **math** module provides a range of trigonometric functions and in this article I will use them to provide a crash course in trigonometry.

# Benford’s Law in Python

In this post I will write a Python implementation of Benford's Law which describes the distribution of the first digits of most sets of numeric data.

I recently posted an article on Zipf's Law and the application of the Zipfian Distribution to word frequencies in a piece of text. Benford's Law can be considered a special case of Zipfian Law.

Continue reading# Zipf’s Law in Python

In this post I will write a project in Python to apply Zipf's Law to analysing word frequencies in a piece of text.

Zipf's Law describes a probability distribution where each frequency is the reciprocal of its rank multiplied by the highest frequency. Therefore the second highest frequency is the highest multiplied by 1/2, the third highest is the highest multiplied by 1/3 and so on.

This is best illustrated with a graph.

Continue reading# Estimating Pi in Python

In this project I will code in Python a few of the methods of estimating Pi.

Pi is an irrational number starting off 3.14159 and then carrying on for an infinite number of digits with no pattern which anybody has ever discovered. Therefore it cannot be calculated as such, just estimated to (in principle) any number of digits.

Continue reading# Frequency Analysis in Python

Simple codes such as substitution cyphers can be cracked or broken using a technique called frequency analysis which I will implement in Python.

In a previous post I implemented a very simple and very insecure substitution cypher. It is insecure because each letter in the original text is always encrypted the same way, for example the most common letter "e" might always be encrypted as "h", so if we find that "h" is the most common letter in the encrypted text then we can assume it represents "e". This can be carried out for all letters, a process called frequency analysis which in this post I will implement in Python.

Continue reading