R/line_sample.R
n_sample_length.RdSample integer number from given continuous vector of line lengths and probabilities, with total n
n_sample_length(n, l_lengths, weights)
| n | Sum of integer values returned |
|---|---|
| l_lengths | Numeric vector of line lengths |
| weights | Relative probabilities of samples on lines |
Other lines:
angle_diff(),
geo_toptail(),
is_linepoint(),
line2df(),
line2points(),
line_bearing(),
line_breakup(),
line_match(),
line_midpoint(),
line_sample(),
line_segment(),
line_via(),
mats2line(),
n_vertices(),
onewaygeo(),
points2line(),
toptail_buff(),
toptailgs(),
update_line_geometry()
n <- 10 l_lengths <- 1:5 weights <- 9:5 (res <- n_sample_length(n, l_lengths, weights))#> [1] 1 2 2 2 3#> [1] 10n <- 100 l_lengths <- c(12, 22, 15, 14) weights <- c(38, 10, 44, 34) (res <- n_sample_length(n, l_lengths, weights))#> [1] 26 12 36 26#> [1] 100#> [1] 0 5 0 0 0#> [1] 2 2 1 0 0#>n <- n_sample_length(10, l_lengths, weights = l$All)