The following data were obtained for thee growth of a sheep population introduced into a new environment on the island of Tasmania (adapted fom J Davidson," On th eGrowth of The Sheep Population in Tasmania," Trans. R.Soc.S. Australia 62(1938): 342-346)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.3
t <- c(1814, 1824, 1834, 1844, 1854, 1864)
p <- c(125, 275, 830, 1200, 1750, 1650)
ggplot(data.frame(x=t,y=p),aes(x=x,y=y, fill = p)) +
geom_line() +
geom_point() +
ggtitle("Sheep Population Growth") +
theme(plot.title = element_text(lineheight=.8, face="bold"))+
xlab("Years")+
ylab("Population")
The sheep population appears to reach a maximum level, and the last data point suggests that the data never exceeded 1750. We estimate M = 1800
Now, let plot Years elapsed and Change p(t+1) - p(t)
yearlapsed<- t-t[1]
p_changes<-0
for (i in 1:length(p)-1) {p_changes<- c(p_changes, p[i+1] -p[i]) }
p_changes
## [1] 0 150 555 370 550 -100
yearlapsed
## [1] 0 10 20 30 40 50
ggplot(data.frame(x=yearlapsed,y=p_changes),aes(x=x,y=y, fill = p_changes)) +
geom_line() +
geom_point() +
ggtitle("Sheep Population Growth Change") +
theme(plot.title = element_text(lineheight=.8, face="bold"))+
xlab("Elapsed Years")+
ylab("Growth Change")
b. Plot ln[P/(M-P)] against t. If a logistic curve seems reasonable, estimate rM and \(t^*\).
# we estimated M = 1850
M <- 1850
#ln [P/ M - P]
ln_pMp <- log(p/(M-p))
# plot ln [P/ M - P] versus t
ggplot(data.frame(x=t,y=ln_pMp),aes(x=x,y=y, fill = ln_pMp)) +
geom_line() +
geom_point() +
ggtitle("ln [P/ M - P] versus t") +
theme(plot.title = element_text(lineheight=.8, face="bold"))+
xlab("Years (t)")+
ylab("ln [P/ M - P]")+
stat_smooth(method="lm")
The above graph does approximate to a straight line. Thus we accept the assumptions of logistic growth for the sheep population.
Next, lets estimate teh slope (rM) of the graph.
rM <- lm(ln_pMp ~ t)
rM <- rM$coefficients["t"]
rM
## t
## 0.1094742
Next, we will find t* using the below formula:
\[ t^* = t_0 - \frac {1} {rM} * \frac {P_0} {M - P_0} \]
t_star <- t[1] - (1/rM)*log(p[1]/(M-p[1]))
t_star
## t
## 1837.975
Therefore, P(t) should be M/2.
Let validate, we have:
p = 830 when t = 1834.
p = 1200 when t = 1844
Then p = M/2 = 1850/2= 925 when t = t= 1837.975 = 1838
Therefore, the logistical model agrees with the population.
Suggest other phenomena for which the model described in the text might be used.
The model described in the text might be used in regulating water pressure. Water pressure regulators automatically reduce the high incoming water pressure from the city mains to provide a more functional pressure for distribution in the home.
They “regulate” by maintaining a set pressure in the home usually 50 lbs. thereby insuring that the horne piping and appliances operate under a safe, more moderate, but satisfactory pressure.
When there is no water pressure regulator and high water pressure occurs in the home plumbing system, it can be damaging because water, with a strong “push” behind it, can erode or wear away many materials and cause leaking water heaters, banging water pipes, dripping faucets, dishwasher and clothes washer noise and breakdown, and leaking water pipes. Therefore, water flowing at a rate in excess of that necessary to satisfy normal fixture or appliance demands becomes damaging, wasteful and reduces the life expectancy of equipment in the system. But, probably most important to the average homeowner is that it can add to the cost of water, energy and waste water bills.
On the other hand, if there is no water pressure regulator and low water pressure occurs, many home won’t have enough water as it won’t reach their properties. Tall buildings will be mostly affected as perhaps only lower apartments or lower offices will have water with low pressure. Finally, it will certainly will be devastating for firefighters as they won’t have enough water pressure to put out fires.
Using the estimate that \(d_b = 0.054 v^2\), where 0.054 has the dimension \(ft.hr^2\)/\(mi^2\).
Show that the constant k in Equation(11.29) has value 19.9ft/\(sec^2\)
First we need to convert hours to second and miles to feet.
We have:
1 hour = 3600 sec
1 mile = 5280 feet
Since \(d_b = 0.054 v^2\) has the dimension \(ft.hr^2\)/\(mi^2\), we need to multiply \(d_b\) by \(3600^2\) second and 1/\(5280^2\) ft
Hence, our \(d_b\) equation becomes: \[ d_b = [.054 * 3600^2 ft * sec^2/hr^2 (\frac {1} {5280^2} ft^2/mil^2)] * v^2 \ \] \[ d_b = [.054 * 3600^2 (\frac {1} {5280^2} ] (ft * sec^2/ft^2) * v^2 \]
Soving \(.054 * 3600^2 (\frac {1} {5280^2}\)
d <- 0.054* (3600^2/5280^2)
d
## [1] 0.02510331
Therefore, our equation becomes: \[d_b = 0.0251*v^2 = \frac {v^2} {2k} (ft * sec^2/ft^2) \]
\[ 0.0251 = \frac {1} {2k} (ft * sec^2/ft^2) \] \[ 0.0251 = \frac {1} {2k} (sec^2/ft) \]
solving for k: \[ k = \frac {1} {2 * .0251} (ft / sec^2) \] from below k is: \[ k = 19.92032 (ft / sec^2) \]
k = 1/ (2 * .0251)
k
## [1] 19.92032
First, I think they meant Table 2.4 which is in page 75 instead of table 4.4.. Therefore, I will assume and the data in Table 2.4 titled “Observed reaction and braking distances”
speed<- c( 20,25,30,35,40,45,50,55,60,65,70,75,80)
breaking_distance<- c(20, 28, 40.5, 52.5, 72, 92.5, 118, 148.5, 182, 220.5, 266, 318, 376)
df <- data.frame(speed, breaking_distance)
df$speed_ftpsec <- df$speed *(5280/3600)
df$v_sqr_over_2 = (df$speed_ftpsec^2) / 2
library(ggplot2)
ggplot(data = df, aes(x=v_sqr_over_2, y=breaking_distance)) +
geom_line() +
geom_point() +
ggtitle("Bd vs. v square over 2") +
theme(plot.title = element_text(lineheight=.8, face="bold"))+
xlab("Speed Square over 2")+
ylab("Breaking Distance")
one_over_k <- lm( df$breaking_distance ~ df$v_sqr_over_2)$coefficients[2]
k = 1/ one_over_k
k
## df$v_sqr_over_2
## 18.31807
Oxygen flows through one tube into a liter flask filled with air, and the mixture of oxygen and air (considered well stirred) escapes through another tube. Assuming that air contains 21% oxygen, what percentage of oxygen will the flask contain after 5L have passed through the intake tube?
In this case we will set up the problem as ‘proportion of oxygen’ vs ‘volume passed through’.
If P(v) is the proportion of Oxygen when a volume v has passed through, then when v=0, P=.21, our initial condition.
Then, our differential equation at any time, if we pass an extra dv of oxygen into the flask, then an amount Pdv comes out. The change in the proportion is:
dP = dv - Pdv (since the flask is 1L), therefore, dP/dv = 1-P.
Therefore, our Deferential Equation, and an initial condition are as follow:
dP/dv = 1-P. and at P(0) = .21
We will use package Desolve to solve the above DE
derivs <- function( r,y, parms)
list(r-y)
library(deSolve)
## Warning: package 'deSolve' was built under R version 3.2.3
##
## Attaching package: 'deSolve'
##
## The following object is masked from 'package:graphics':
##
## matplot
yini = .21
volums <- seq(from = 0, to = 5, by = 0.2)
out <- ode(y = yini, times = volums, func = derivs, parms = NULL)
out
## time 1
## 1 0.0 0.2100000
## 2 0.2 0.1906654
## 3 0.4 0.2110880
## 4 0.6 0.2640625
## 5 0.8 0.3436873
## 6 1.0 0.4451348
## 7 1.2 0.5644459
## 8 1.4 0.6983833
## 9 1.6 0.8442956
## 10 1.8 1.0000124
## 11 2.0 1.1637564
## 12 2.2 1.3340726
## 13 2.4 1.5097695
## 14 2.6 1.6898717
## 15 2.8 1.8735808
## 16 3.0 2.0602429
## 17 3.2 2.2493228
## 18 3.4 2.4403821
## 19 3.6 2.6330621
## 20 3.8 2.8270690
## 21 4.0 3.0221622
## 22 4.2 3.2181449
## 23 4.4 3.4148558
## 24 4.6 3.6121629
## 25 4.8 3.8099582
## 26 5.0 4.0081531
# Therefore, the precentage of oxygen that flask will contain after 5 L is:
# 4.0081531 Liters.