[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

st_line_sample type = "regular" are not regular #299

Closed
joethorley opened this issue Apr 12, 2017 · 14 comments
Closed

st_line_sample type = "regular" are not regular #299

joethorley opened this issue Apr 12, 2017 · 14 comments

Comments

@joethorley
Copy link
Contributor

the regular function in st_line_sample with n = 3 takes samples at 1/6, 3/6, 5/6 spacings.

regular = function(n) { (1:n - 0.5)/n }

I'm thinking a replacement or alternative (type = "equidistant"?) should be

regular = function(n) { 1:n / (n + 1) }

which with n = 3 give samples at 1/4, 2/4 and 3/4 spacings.

I'm happy to do a pull request if you agree.

@edzer
Copy link
Member
edzer commented Apr 12, 2017

Would you argue that 1/6, 3/6 and 5/6 are not equidistant? What's the compelling use case to add this?

@joethorley
Copy link
Contributor Author

They are not equidistant in the sense that the line is not broken into equal length segments. If one only focuses on the distance between the intermediate points then one can argue that 1/10, 5/10 and 9/10 are just as equidistant as 1/6, 3/6 and 5/6. We are trying to use the function to reconstruct the position of individuals at equal intervals as they move from point A to point B. We know where they are at the start and end and want to know where they are when they are 1/4, 2/4 and 3/4 of the way along.

@edzer
Copy link
Member
edzer commented Apr 13, 2017

Don't you want 0 and 1 included, then?

@joethorley
Copy link
Contributor Author

You can argue it either way - since they are easy to include or exclude. I would prefer 0 and 1 be included.

@joethorley
Copy link
Contributor Author

the only trouble is if one sets n = 1 it is not possible to include 0 and 1.

@joethorley
Copy link
Contributor Author

I guess one could go
n = 1: 1/2
n = 2 0/2 and 2/2
n = 3 0/2 and 1/2 and 2/2

@edzer
Copy link
Member
edzer commented Apr 13, 2017

How about adding an argument, e.g. sample, that should take numbers between 0 and 1 (inclusive) that are then being used instead of fn(n[i])?

@joethorley
Copy link
Contributor Author

I like that idea. Do you want me to implement? and do you think sample should replace the arguments n, density and type?

@edzer
Copy link
Member
edzer commented Apr 13, 2017

Yes; no, but it shall overrule them.

@joethorley
Copy link
Contributor Author

Roger that - await my pull request!

@joethorley
Copy link
Contributor Author

Seems to me little point in passing a function unless it is going to use n i.e. unless it takes one or more arguments all it is going to do is return a vector of numbers between 0 and 1. Would you like sample to be a vector of numbers between 0 and 1 or would you like sample to take n (or another argument)?

@edzer
Copy link
Member
edzer commented Apr 13, 2017

a vector with numbers between 0 and 1 inclusive.

@joethorley
Copy link
Contributor Author

Roger that

@joethorley
Copy link
Contributor Author

pull request
#300

@edzer edzer closed this as completed Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants