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

这里好像有点问题 #5

Open
yueg opened this issue Nov 10, 2017 · 1 comment
Open

这里好像有点问题 #5

yueg opened this issue Nov 10, 2017 · 1 comment

Comments

@yueg
Copy link

yueg commented Nov 10, 2017

curr / seq[i][-1] - 1.0 for i, curr in enumerate(seq[1:])]

是不是应该改为
seq = [seq[0] / seq[0][0] - 1.0] + [curr / seq[i-1][-1] - 1.0 for i, curr in enumerate(seq[1:])]

@lilianweng
Copy link
Owner

Let's check!

from __future__ import division
import numpy as np

def split_and_normalize_prices(seq, input_size):
    seq = [np.array(seq[i * input_size: (i + 1) * input_size]) for i in range(len(seq) // input_size)]
    print "After split:", seq
    seq = [seq[0] / seq[0][0] - 1.0] + [curr / seq[i][-1] - 1.0 for i, curr in enumerate(seq[1:])]
    print "After normalization:", seq
    return seq

With this function defined, split_and_normalize_prices(range(1, 11), 4) prints out:

After split: [array([1, 2, 3, 4]), array([5, 6, 7, 8])]
After normalization: [array([ 0.,  1.,  2.,  3.]), array([ 0.25,  0.5 ,  0.75,  1.  ])]

I believe this is expected behavior :)

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