April 28, 2020

## Midterm exam

• I will send it today
• It will be a long homework
• Strictly personal
• Zero tolerance with cheating
• File format: Rmd, to include English text
• Use the correct format
• Send answers to the correct email

## Format issues

The homework assignment asked for Rmd format

But 40% of answers were in R format

Makrdown rules are important

The file should produce a correct output

## Example of Format issues

-This system have two
parts(elements)(values in
the circle) which are
{food and cells}
-The system have one
processes (box) which
is {eating}

-This system have two parts(elements)(values in the circle) which are {food and cells} -The system have one processes (box) which is {eating}

There should be a space after -. Use a single * to wrap keywords

## Correct format

- This system has two
parts(elements) (values
in the circle), which
are *food* and *cells*
- The system has one
processes (box) which
is *eating*

• This system has two parts (elements) (values in the circle), which are food and cells
• The system has one processes (box) which is eating

Check your English grammar: “The system has parts…” because system is singular.

## Example of Format issues

system's parts; food, cells
process rates; ncells[i-1]*food[i-1]/food[1]
initial values : ncell[1], food[1]
when food is finish cells will stop replicating and start dying.

system’s parts; food, cells process rates; ncells[i-1]*food[i-1]/food[1] initial values : ncell[1], food[1] when food is finish cells will stop replicating and start dying.

## Correct format

### Using lists

+ system's parts: food, cells
+ process rates: ncells[i-1]*food[i-1]/food[1]
+ initial values: ncell[1], food[1]
+ when food is finish cells will stop replicating and start dying.
• system’s parts: food, cells
• process rates: ncells[i-1]*food[i-1]/food[1]
• initial values: ncell[1], food[1]
• when food is finish cells will stop replicating and start dying.

## Other option

### Separate lines

system's parts: food, cells

process rates: ncells[i-1]*food[i-1]/food[1]

initial values: ncell[1], food[1]

when food is finish cells will stop replicating and start dying.

system’s parts: food, cells

process rates: ncells[i-1]*food[i-1]/food[1]

initial values: ncell[1], food[1]

when food is finish cells will stop replicating and start dying.

## Correct Markdown format

• Separate paragraphs with empty lines
• If you use lists, write space after the +
• You can also use - and * at the line start
• I find that + is more positive
• Use a back-tick  to mark variables
• Use a single * to wrap keywords

## Correct English symbols

• Use : to start a description, no ;
• Always space after dots . and commas ,
• Never space before dots . and commas ,
• Never space inside parenthesis
• Bad: … one item( circle )…
• Good: … one item (circle) …

## Do not repeat me

• I’m not testing your memory

• Do not tell me

“A system is a group of interacting parts. The behavior of the system depends on the parts and interaction.”

• Just tell me what do you think will be the behavior

## Describe the system as it is

May people said something like “when food is finish cells will stop replicating and start dying”

But there is no dying process in the figure

Therefore, in that model, cells never die

You are confusing your mental model with the exercise model

## But cells should die

You are right. But this is a model, not reality

It means that the model is incomplete, and you should complete it

• How would you change the system to make it more realistic?

## Rates

• Each box has a single rate
• Somebody said
• “process rate: ncells[i-1]*food[i-1]/food[1]
• Wrong!
• Process is eating
• Process rate is eating_rate

## Base code

system_name <- function(N, rates, initial_cond) {
state   <- d_state <- rep(NA, N)
state[1] <- initial_cond
d_state[1]  <- 0
for(i in 2:N) {
d_state[i] <- some formula
state[i]  <- state[i-1] + d_state[i]
}
return(data.frame(state, d_state))
}`