Created
August 13, 2020 07:11
-
-
Save saimadhu-polamuri/cd08bdaca3dda287ad26aa8164ddebe8 to your computer and use it in GitHub Desktop.
Code for the article published in https://dataaspirant.com
This file contains 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
""" | |
=============================================== | |
Objective: Implementing Markov Chains model | |
Author: Venkatesh Nagilla | |
Blog: https://dataaspirant.com | |
Date: 2020-08-09 | |
=============================================== | |
""" | |
import pymc3 as pm | |
model = pm.Model() | |
import pymc3.distributions.continuous as pmc | |
import pymc3.distributions.discrete as pmd | |
import pymc3.math as pmm | |
with model: | |
passenger_onboarding = pmc.Wald('Passenger Onboarding', mu=0.5, lam=0.2) | |
refueling = pmc.Wald('Refueling', mu=0.25, lam=0.5) | |
departure_traffic_delay = pmc.Wald('Departure Traffic Delay', mu=0.1, lam=0.2) | |
departure_time = pm.Deterministic('Departure Time', | |
12.0 + departure_traffic_delay + | |
pmm.switch(passenger_onboarding >= refueling, | |
passenger_onboarding, | |
refueling)) | |
rough_weather = pmd.Bernoulli('Rough Weather', p=0.35) | |
flight_time = pmc.Exponential('Flight Time', lam=0.5 - (0.1 * rough_weather)) | |
arrival_traffic_delay = pmc.Wald('Arrival Traffic Delay', mu=0.1, lam=0.2) | |
arrival_time = pm.Deterministic('Arrival time', | |
departure_time + | |
flight_time + | |
arrival_traffic_delay) | |
nb_samples = 500 | |
with model: | |
samples = pm.sample(draws=nb_samples, random_seed=1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment