Learn R Programming

dslabs (version 0.7.1)

rfalling_object: Simulate falling object data

Description

The function simulates a falling object's position. Default parameters are for dropping a weight from the tower of Pisa.

Usage

rfalling_object(n = 14, d_0 = 55.86, v_0 = 0, g = -9.8,
  scale = 1, time = seq(0, 3.25, length.out = n),
  error_distribution = c("rnorm", "rt"), df = 3)

Arguments

n

Sample size

d_0

Height from which object will fall in meters.

v_0

Initial velocity with which object will fall in meters per second.

g

Gravitational constant, 9.8 meters per second per seonnd

scale

The measurement errors will be multiplied by this constant.

time

Numeric vector of times, in seconds, at which measurements were taken.

error_distribution

Character. Either rnorm for normal or rt for t-distribution.

df

If using t-distribution, the degrees of freedom.

Value

A data.frame with the time, the distance travelled, and the observed distance.

Examples

Run this code
# NOT RUN {
dat <- rfalling_object()
with(dat, plot(time, observed_distance))
with(dat, lines(time, distance, col = "blue"))

# }

Run the code above in your browser using DataLab