Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97309
| References | <muk61h$eka$1@speranza.aioe.org> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2015-10-01 15:10 -0600 |
| Subject | Re: Generating a vector from successive multiplications of another vector from an initial value |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.310.1443733899.28679.python-list@python.org> (permalink) |
On Thu, Oct 1, 2015 at 2:45 PM, Paulo da Silva
<p_s_d_a_s_i_l_v_a_ns@netcabo.pt> wrote:
> Hi all.
>
> What is the fastest way to do the following:
>
> I have an initial value V and a vector vec of (financial) indexes.
> I want to generate a new vector nvec as
>
> V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ...
>
> A numpy vectorized solution would be better.
That looks hard to vectorize since each calculation depends on the
previous. You might be stuck with something like:
result = [V]
for x in vec:
result.append(result[-1] * x)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Generating a vector from successive multiplications of another vector from an initial value Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2015-10-01 21:45 +0100 Re: Generating a vector from successive multiplications of another vector from an initial value Ian Kelly <ian.g.kelly@gmail.com> - 2015-10-01 15:10 -0600 Re: Generating a vector from successive multiplications of another vector from an initial value duncan smith <buzzard@invalid.invalid> - 2015-10-02 00:44 +0100 Re: Generating a vector from successive multiplications of another vector from an initial value Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2015-10-02 02:01 +0100
csiph-web