Created
May 19, 2021 09:18
-
-
Save 18182324/10d41211b442cb5e6121a6b4ad42c954 to your computer and use it in GitHub Desktop.
Deep Learning Probability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: #If running in colab | |
import google.colab | |
IN_COLAB = True | |
%tensorflow_version 2.x | |
except: | |
IN_COLAB = False | |
import tensorflow as tf | |
if (not tf.__version__.startswith('2')): #Checking if tf 2.0 is installed | |
print('Please install tensorflow 2.0 to run this notebook') | |
print('Tensorflow version: ',tf.__version__, ' running in colab?: ', IN_COLAB) | |
#load required libraries: | |
import numpy as np | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
plt.style.use('default') | |
# Assume a die with only one face with a joker sign | |
# Calculate probability to observe in 6 throws 1- or 2-times the J-sign | |
6*(1/6)*(5/6)**5, 15*(1/6)**2*(5/6)**4 | |
from scipy.stats import binom | |
# Define the numbers of possible successes (0 to 6) | |
njoker = np.asarray(np.linspace(0,6,7), dtype='int') | |
# Calculate probability to get the different number of possible successes | |
pjoker_sign = binom.pmf(k=njoker, n=6, p=1/6) | |
plt.stem(njoker, pjoker_sign) | |
plt.xlabel('Number of Joker signs') | |
plt.ylabel('Probability') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment