View Linear_model.R
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
#------------------------------------------------------------------------------- | |
# Another linear model using more information y = a*x1 + b*x2 + c*x3 + d*x4 | |
#------------------------------------------------------------------------------- | |
# Plot data | |
plot(disp,wt,type='p',xlab='Disp',ylab='Wt',main='Linear regression') | |
# Add a legend | |
legend("topleft",c("Observ.","Predicted"), col=c("black","red"), lwd=3) |
View arrivalTimes1.R
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
#------------------------------------------------------------------------------- | |
# Loading data | |
#------------------------------------------------------------------------------- | |
# Observed data | |
data <- read.csv('data.txt',header=T) | |
# Take a look of the data | |
View(data) |
View arrivalTimes2.R
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
#------------------------------------------------------------------------------- | |
# Simulation | |
#------------------------------------------------------------------------------- | |
# Estimated parameters of the exponential distribution | |
x.rate <- length(data$num) | |
# Remember that mean = 1/x.rate | |
# meaning that, on average, we expect a new arrival every 1/74 of an hour. | |
# (1/74 =~ 0.01355) |
View arrivalTimes3.R
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
#------------------------------------------------------------------------------- | |
# Compare simulated to obseved data | |
#------------------------------------------------------------------------------- | |
# Let's compare observed data with simulated data | |
# Comparative boxplot | |
boxplot(interarrivals,simulated.min,xlab='Minutes',col=c('cyan','chartreuse'), | |
border=c('blue','seagreen'),names=c('Observed','Simulated'), | |
main='Interarrival times',notch=TRUE,horizontal=TRUE) |
View arrivalTimes4.R
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
#------------------------------------------------------------------------------- | |
# Probability distributions | |
#------------------------------------------------------------------------------- | |
# Density plot | |
#Since the rate is given as person/hour we need to set time in hours | |
#Initial time Final time Step | |
#0 hour 0.15 of an hour 0.001 of an hour | |
#0 minutes 9 minutes 0.06 minutes = 3.6 seconds |
View waveEquation.py
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
import numpy as np | |
from numpy import pi | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
plt.style.use('dark_background') | |
fig = plt.figure() | |
fig.set_dpi(100) | |
ax1 = fig.add_subplot(1,1,1) |
View RCRL.py
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
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.style.use('ggplot') | |
l = 0.0229 #Inductance (H) | |
r = 3.34 #Resistance (Ohm) | |
v = 5 #Voltage (V) DC | |
i = v/r #Peak current (A) | |
tau = l/r #Tau time constant |
View RC.py
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
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.style.use('ggplot') | |
c = 100 * 10**(-6) | |
v = 5 | |
r = 2000 | |
t = np.linspace(0,1,1000) |
View transportEq.py
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
#Transport equation with decay implementation | |
import numpy as np | |
from numpy import pi | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
fig = plt.figure() | |
fig.set_dpi(100) | |
ax1 = fig.add_subplot(1,1,1) |
View heatEquation2.py
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
import numpy as np | |
from numpy import pi | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
fig = plt.figure() | |
fig.set_dpi(100) | |
ax1 = fig.add_subplot(1,1,1) | |
#Diffusion constant |