Bayesian statistics is fun. But it is also very hard. What is the probability that it is a hard subject, given that it is already fun? This may not be a very useful question to ask, but it gets to the heart of what Bayesian statistics (and inference) is all about: looking at past data or evidence to make predictions about the future. It is a foundational topic in any course involving data science or machine learning, but it still remains very inaccessible to most people because of the way it is taught.

There are essentially two ways in which…

Done from scratch using less than 200 lines of code.

The other day I was working with some Python and functions, and it occurred to me that it would be a fun task to program a Connect-4 game from scratch using a few functions and a data structure known as a stack. Programming board games is a fun activity for two reasons: (1) it teaches you how to think out of the box when it comes to coding and algorithms, and (2) it is an interactive process in which the end result is quite satisfactory.

A guide using simple Python code.

In my previous story (https://oscarnieves100.medium.com/simulating-correlated-random-variables-in-python-c3947f2dbb10) I discussed how to simulate correlated random numbers from a normal probability distribution. We focused on a normal distribution because it is well known, and standard methods of sampling exist.

But what if you wanted to create your own probability distribution? What if I told you that you don’t need to be constrained by any of the well-known probability distributions out there? Where there is a will, there is a way, and what I am about to show you is very simple yet very powerful.

First, let us establish…

In my previous Medium story (https://oscarnieves100.medium.com/simulating-normal-random-numbers-in-python-18a2a21a1329) I discussed how to simulate normal random numbers with specific mean and variance properties by using something called the Box-Muller method. The idea was to take a set of independently sampled uniform random numbers, and convert them into normal random numbers by using a transformation involving polar coordinates, giving us two uncorrelated normal variables X and Y.

This is all good and fun, however when sampling numbers like this in a computer program, we always get “uncorrelated” variables. Correlation is a measure of how well a variable Y is described by a variable X…

Using the Box-Muller method

In my previous Medium story: https://oscarnieves100.medium.com/how-to-simulate-random-numbers-dad35905ecdb I discussed how to simulate random numbers in Python by using a little mathematical method known as “the inverse sampling theorem”. In it, I demonstrated how using nothing but uniformly distributed random numbers in the interval [0, 1] we could produce a set of random numbers from an exponential distribution, as shown in the Figure below:

A gentle introduction

Random numbers are used in a lot of applications. They are more predominantly used in areas like statistics, probability theory, data science, signal processing, statistical physics, machine learning, actuarial science, quantitative finance, and more. Yet they can be a bit challenging to understand due to their… well, random nature.

First, we need to come clean about something. Random numbers generated in computers are not truly random, in fact they are referred to as “pseudo-random” numbers. The reason for this is that they are basically constructed from a huge number of digit sequences which are then converted into…

Students of science and engineering often only learn a bit of Excel in the context of doing simple data analysis, plotting and calculations involving single cells or scalar values (e.g. basic statistics). However, there are many ways in which Excel can be used for a lot of other calculations, including things like linear algebra, regression analysis, probability computations, and even numerical solutions to differential equations. We can do a lot of these things without even knowing a thing about VBA programming.

In this short tutorial, I will go over some important functions in Excel which can be used for performing…

And understand it properly.

Statistics is a huge field of study. Most people only come across some statistics in school, and perhaps at university. Unless you have done a dedicated degree in data science, mathematics/statistics, quantitative finance or actuarial science; chances are you probably know very little. In fact, so little that you don’t know how to make use of the knowledge you have, which kind of defeats the purpose of knowing any statistics at all.

But it’s not people’s fault. I mean, I have qualifications in physics and even then my knowledge of statistics is extremely limited. I have…

Gaussian integrals occur quite often in science, statistics, and probability theory. In fact, if you have ever come across the normal distribution in statistics — also known as the “Bell curve” — you probably know what a Gaussian function is, or at least what it looks like.

A Gaussian integral is essentially the area under the Gaussian function, between set limits along the horizontal axis. …

And how far to go with it.

Physics is a difficult thing to study. Not just because it requires a lot of mathematics, but also because it requires a lot of patience, dedication and time. Most people only learn physics in high school, and never touch on the subject again, perhaps they don’t need it, or they go into a profession which doesn’t require any knowledge of physics. Whichever the case may be, there are certainly wrong and right approaches to learning physics. In this short article, I will explain how to get the most out of your learning. This…