normally. with data I work with, it's not really just a vector: i.e data=. 1 2 
3 4
it usually is a matrix like:
   [data=. i. 5 4
 0  1  2  3
 4  5  6  7
 8  9 10 11
12 13 14 15
16 17 18 19

So to apply Bo's solution:
   'A B C D'=. < "1 |: data
   A
0 4 8 12 16
   B
1 5 9 13 17
   C
2 6 10 14 18
   D
3 7 11 15 19

Which would give us:
    ((A+B)*C)+D
5 61 181 365 613

:)


On Apr 28, 2010, at 7:59 PM, Bo Jacoby wrote:

> There is a shorthand for multiple assignments:
>   'A B C D'=.0.2 12 0 4
> meaning
>   A=.0.2
>   B=.12
>   C=.0 
>   D=.4
> then evaluate
>   (A+B)*C+D
> 48.8
> 
> meaning 
>   (A+B)*(C+D)
> 48.8
> 
> or
>   ((A+B)*C)+D
> 4
> 
> if that is what you wanted.
> 
> Is this what you need?
> 
> 
> --- Den ons 28/4/10 skrev Joe Bohart <[email protected]>:
> 
>> Fra: Joe Bohart <[email protected]>
>> Emne: [Jprogramming] right way to think in J (problem Expected Volatility 
>> from High Frequency Finance)
>> Til: [email protected]
>> Dato: onsdag 28. april 2010 13.30
>> Hi All,
>> 
>> Been learning J for a bout a year now and very impressed -
>> although it's a
>> mind bend. I feel my understanding of complex problem is
>> clearer however i
>> have yet to actual code something interesting in J.
>> 
>> Here is an interesting problem that I'd like some input
>> on......
>> 
>> I'm trying to implement an Expected Volatility equation
>> 4.20 from the book
>> (by the Olson group) High Frequency Finance
>> in J and I'm curious if this is the correct J-way of
>> solving a simplified
>> subset of the problem:
>> 
>> ExpectedVolatility = (A + B) * C + D
>> 
>> so super simple problem reduction:
>> data =: 1 2 3 4
>> goal (non j notation): (1+2)*3 + 4
>> 1st-cut: (0{data + 1{data) * 2{data + 3{data
>> 2nd-cut: +/ 0 1 & { data * 2{data + 3{data
>> 3rd-cut: I'm sure there is a more elegent way to do this,
>> maybe using forks
>> ????
>> 
>> I'm curious if the following is the correct way to go about
>> solving problems
>> in a J-way:
>> The actuality data matrix would be something like:
>> (datetime,px,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
>> 
>> I need a verb to transform this noun
>> (datetime,px,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
>> into this (easy to digest noun)
>> (A B C D)
>> where i have not defined the relation,
>> then I'd need another verb to transform the easy to digest
>> noun into the
>> Expected Volatility noun where i have defined the relation
>> above (but
>> probably not in an elegant j-way).
>> 
>> Am i on the right path for thinking in J, thoughts,
>> comments...greatly
>> appreciated.
>> 
>> Thanks,
>> Joe
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> 
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to