-
Notifications
You must be signed in to change notification settings - Fork 629
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
fix scalar random samplng #57
fix scalar random samplng #57
Conversation
Superjomn
commented
Jan 4, 2018
- changing form random sample to equidistant sampling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
end_idx = len(data) - 1 | ||
res = [] | ||
for i in xrange(num_records): | ||
id = int(end_idx - i * span) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id 是 python保留字,建议换一个
span = float(len(data) / num_records) | ||
end_idx = len(data) - 1 | ||
res = [] | ||
for i in xrange(num_records): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里逻辑有点问题。取 n 个点的话, 应该除以 (n-1),比如 10个点取三个,应该是 10/2 = 5, 取 0, 5 , 9
span = float(len(data)) / (num_records-1)
span_multiply = 0
data_idx = int(span_multiply * span)
sampled_data = []
while data_idx < len(data):
sampled_data.append(data[data_idx])
span_multiply += 1
data_idx = int(span_multiply * span)
sampled_data.append(data[-1])
return sampled_data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在是 10个点取3个的话:
9, 5, 0
reverse-> 0, 5, 9
这个应该没有问题 @daming-lu