Good point, Raul.

If i =. 0.27 for example, my explicit formula blows up.

What I was trying to do was emulate a standard sequence function in Octave
which has the following syntax:
>> e:i:s
ans = 5.00000 5.25000 5.50000 5.75000 6.00000 6.25000 6.50000 6.75000
7.00000 7.25000 7.50000 7.75000 8.00000

In our Machine Learning homework we use this sequence-generating function
often, so I thought I would see if I could duplicate the function in J.
However, to fit J's dyadic syntax, I put s & e as the left argument of the
function, and the increment i as the right argument. If you feel that there
is a better way to place the three args around the dyadic function, feel
free to propose that.

However, in Octave:
>> i = 0.27;
>> e:i:s
ans = 5.00000 5.27000 5.54000 5.81000 6.08000 6.35000 6.62000 6.89000
7.16000 7.43000 7.70000 7.97000

Octave doesn't blow up when (e-s)%i is not an integer. It just ends the
sequence before it exceeds e. So I need to fix my explicit equation:

s + i *  i. <. 1 +(e-s) %  i

Taking the floor of 1+(e-s)%i  solves the case when the division is not an
integer.

   s =. 5
   e =. 8
   i =. 0.27
   s + i *  i. <. 1 +(e-s) %  i
5 5.27 5.54 5.81 6.08 6.35 6.62 6.89 7.16 7.43 7.7 7.97

That seems to duplicate the Octave function, but it makes our tacit version
in J a bit more complex.

On Thu, Aug 23, 2012 at 8:41 AM, Raul Miller <[email protected]> wrote:

> ........
>
> That said, note that most of the work here has to do with dealing with
> the arguments in the form you specified.  And, also, note that you
> have a dependency between s,e and i -- if (e-s)%i is not an integer
> you get an error.
>
> So, personally, I would ask why you need to be doing this this way --
> what are you really trying to accomplish?
>
> Thanks,
> --
> Raul
>
>


-- 
Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to