Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Become a Python Data Analyst

You're reading from   Become a Python Data Analyst Perform exploratory data analysis and gain insight into scientific computing using Python

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789531701
Length 178 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alvaro Fuentes Alvaro Fuentes
Author Profile Icon Alvaro Fuentes
Alvaro Fuentes
Arrow right icon
View More author details
Toc

Using NumPy for simulations

Now let's learn how to use NumPy in a real-world scenario. Here, we will cover two examples of simulations using NumPy, and in the process, we will also learn about other operations that we can do with arrays.

Coin flips

We will look into a coin flip, or coin toss, simulation using NumPy. For this purpose, we will use the randint function that comes in the random submodule from NumPy. This function takes the low, high, and size arguments, which will be the range of random integers that we want for the output. So, in this case, we want the output to be either 0 or 1, so the value for low will be 0 and high will be 2 but not including 2. Here, the size argument will define the number of random...

You have been reading a chapter from
Become a Python Data Analyst
Published in: Aug 2018
Publisher: Packt
ISBN-13: 9781789531701
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image