{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Gerando Números Aleatórios com NumPy" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Importando a Biblioteca NumPy" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Gerando um número aleatório da distribuição normal" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.2981387866460097" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.random.normal()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Gerando quatro números aleatórios da distribuição normal" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([-0.94162726, 0.73114325, 1.62381952, -1.35767931])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.random.normal(size=4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Gerando cinco números aleatórios da distribuição uniforme" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.82738022, 0.55919765, 0.01257903, 0.73969161, 0.41448139])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.random.uniform(size=5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Gerando dez números inteiros aleatórios entre 1 e 100" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([74, 36, 79, 24, 67, 16, 43, 71, 53, 99])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.random.randint(low=1, high=100, size=10)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }