CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Project: LUC2
Views: 32
︠bbc0d199-8c1e-4a04-b2c1-01d6ae5c3b23s︠ %default_mode r
︠46a8ffd8-b04c-418a-8dfd-8d4271e39b77s︠ #project 7 calculations #exponential growth model p_expon=33759742*(1.0080)^(c(0,5,10,15,20,25,30,35,40)) #affine model p(n)=1.0024*p(n-1)+189055 #define parameter values: par1<-1.0024 par2<-189055 #number of time steps to be computed: nmax=40 #create a vector to store the results for each time step: p_sequence=c(0:nmax) #choose an initial value and put it in the element of the vector: p=33759742 #use a loop to compute the values: for(i in 1:(nmax+1)) {p_sequence[i]=p; pnext=par1*p+par2; p<-pnext; } p_aff=p_sequence[c(0,5,10,15,20,25,30,35,40)+1] p_meas=c(33759742,35099836,36387359,37558781,38564870,39395855,40070226,40635090,41135648) p_all=cbind(p_expon,p_aff,p_meas) timeseq=c(0,5,10,15,20,25,30,35,40) matplot(timeseq,p_all,pch=20,type="b",xlab="n",ylab="population size") #percentage difference affine = census after 10 years: 100*(p_aff[3]-p_meas[3])/p_meas[3] #after 40 years: 100*(p_aff[9]-p_meas[9])/p_meas[9] #modified model #define parameter values: par1<-1.0012 par2<-139600 #number of time steps to be computed: nmax=40 #create a vector to store the results for each time step: p_sequence=c(0:nmax) #choose an initial value and put it in the element of the vector: p=33759742 #use a loop to compute the values: for(i in 1:(nmax+1)) {p_sequence[i]=p; pnext=par1*p+par2; p<-pnext; } p_sequence[41]-p_meas[9]
x<-c(1:100) y<-log(x) plot(x,y) #provides a plot with open circles
plot(x,y,pch=".") #gives a plot with points
plot(x,y,pch=20) #gives a plot with bullet points
︠01786e8e-7079-45d3-a6e3-86c718356954s︠ plot(x,y,type="l") #gives a line plot
plot(x,y,pch=20,col="red") #gives a plot with red bullet points
︠f7e9ee75-c366-4145-948d-d60cda28740c︠