NumPy – Binomial Distribution

Binomial Distribution is a Discrete Distribution. It describes the outcome of binary scenarios, e.g. toss of a coin, it will either be head or tails. It has three parameters: n – number of trials. p – probability of occurrence of…

NumPy – Normal Distribution

The Normal Distribution is one of the most important distributions. It is also called the Gaussian Distribution after the German mathematician Carl Friedrich Gauss. It fits the probability distribution of many events, eg. IQ Scores, Heartbeat etc. Use the random.normal()…

NumPy – Seaborn

Visualize Distributions With Seaborn Seaborn is a library that uses Matplotlib underneath to plot graphs. It will be used to visualize random distributions. Install Seaborn. If you have Python and PIP already installed on a system, install it using this…

NumPy – Random Permutations

Random Permutations of Elements A permutation refers to an arrangement of elements. e.g. [3, 2, 1] is a permutation of [1, 2, 3] and vice-versa. The NumPy Random module provides two methods for this: shuffle() and permutation(). Shuffling Arrays Shuffle…

NumPy – Random Data Distribution

What is Data Distribution? Data Distribution is a list of all possible values, and how often each value occurs. Such lists are important when working with statistics and data science. The random module offer methods that returns randomly generated data…

NumPy – Random Numbers

What is a Random Number? Random number does NOT mean a different number every time. Random means something that can not be predicted logically. Pseudo Random and True Random. Computers work on programs, and programs are definitive set of instructions.…

NumPy – Filter Array

Filtering Arrays Getting some elements out of an existing array and creating a new array out of them is called filtering. In NumPy, you filter an array using a boolean index list. A boolean index list is a list of…

NumPy – Sorting Arrays

Sorting Arrays Sorting means putting elements in an ordered sequence. Ordered sequence is any sequence that has an order corresponding to elements, like numeric or alphabetical, ascending or descending. The NumPy ndarray object has a function called sort(), that will…

NumPy – Searching Arrays

Searching Arrays You can search an array for a certain value, and return the indexes that get a match. To search an array, use the where() method. Example Find the indexes where the value is 4: import numpy as np…

NumPy – Splitting Array

Splitting NumPy Arrays Splitting is reverse operation of Joining. Joining merges multiple arrays into one and Splitting breaks one array into multiple. We use array_split() for splitting arrays, we pass it the array we want to split and the number…

NumPy – Joining Array

Joining NumPy Arrays Joining means putting contents of two or more arrays in a single array. In SQL we join tables based on a key, whereas in NumPy we join arrays by axes. We pass a sequence of arrays that…

NumPy – Array Iterating

Iterating Arrays Iterating means going through elements one by one. As we deal with multi-dimensional arrays in numpy, we can do this using basic for loop of python. If we iterate on a 1-D array it will go through each…