{{ message }}

Instantly share code, notes, and snippets.

# Michy mick001

Created Aug 28, 2015
Linear model with 4 variables in R
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)
Last active Jan 17, 2021
Estimating arrival times of people in a shop using R. Part 1. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/07/estimating-arrival-times-of-people-in.html
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
Created Aug 28, 2015
Estimating arrival times of people in a shop using R. Part 2. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/07/estimating-arrival-times-of-people-in.html
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)
Created Aug 28, 2015
Estimating arrival times of people in a shop using R. Part 3. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/07/estimating-arrival-times-of-people-in.html
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)
Created Aug 28, 2015
Estimating arrival times of people in a shop using R. Part 4. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/07/estimating-arrival-times-of-people-in.html
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
Last active Aug 28, 2015
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)
Created Aug 28, 2015
RC RL circuits, a Python simulation, part 1. Full article at http://www.firsttimeprogrammer.blogspot.com/2015/07/electric-circuits-101-rc-and-rl-circuits.html
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
Created Aug 28, 2015
RC RL circuits, a Python simulation, part 2. Full article at http://www.firsttimeprogrammer.blogspot.com/2015/07/electric-circuits-101-rc-and-rl-circuits.html
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)
Created Aug 28, 2015
Transport equation with decay, a Python implementation. Full article can be found at http://www.firsttimeprogrammer.blogspot.com/2015/07/pdes-time-again-transport-equation.html
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)
Last active Aug 28, 2015
Heat Equation part 2 a slight modification. Full article can be found at http://www.firsttimeprogrammer.blogspot.com/2015/07/heat-equation-part-2-slight-modification.html
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