Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread 'Bo Jacoby' via Programming
DevonMcCormick's example
C: |__n0 |   |_n00 |   |_n01 | |__n1  |__n10  |   |__n100  |__n11  |   |__n110  
|   |__n111  |   |__n112  |__n12

is expressed by ordinal fraction like this:

0 |__1 |   |__11 |   |__12 | |__2  |__21  |   |__211  |__22
 |   |__221  |   |__222  |   |__223  |__23

This tree is represented by 

'0 1 11 12 2 21 211 22 221 222 223 23'
or
'000 100 110 120 200 210 211 220 221 222 223 230'

Note 

1. that ordinal fractions are one-origin-indexed unlike J-arrays that 
are zero-origin-indexed

2. that ordinal fractions are left-justified unlike integers that are 
right-justified  
3. that ordinal fractions may be zeropadded to the right (23=230), 
unlike integers that may be zeropadded to the left. (23=023)
4. that ordinal fractions also represents general arrays using zero as 
a general wild-card character.
5. the ordering is alphabetic unlike Devon's which is breadth-first 

for your information.

Bo.



Den 22:55 mandag den 8. september 2014 skrev 'Pascal Jasmin' via Programming 
:
 

>
>
>I think that is awesome, Thomas.  For those who didn't load the code, its much 
>easier to use than it looks as everything is a verb, and the whole thing is 
>like a mini stack language, and each operation produces intuitive and visible 
>results.
>
>
>
>
>- Original Message -
>From: Thomas Costigliola 
>To: J Programming Forum 
>Cc: 
>Sent: Monday, September 8, 2014 4:04 PM
>Subject: Re: [Jprogramming] Ragged Array Shapes are Trees
>
>Array representations and "pointer" representations of trees both have
>their uses. In the end it depends on what problem you are trying to solve.
>As Devon demonstrated, for his purpose, array representation was not a
>hindrance at all. But, as Dan mentions, trees are also used to implement
>abstract data structures with certain run-time properties where finding the
>children of a node or inserting / moving sub-trees in less than constant
>time is not acceptable. J already can do the "pointer" representation with
>boxed arrays but as stated by others previously, there are insufficient
>primitives for working with them conveniently without additional overhead.
>
>I have played around with code similar to Pascal's for working with trees.
>I felt, however, this type of stuff has limited usefulness in production
>code without help from the interpreter to optimize it. It's the same idea
>as a "zipper" data structure in other languages. Here is a bare bones
>implementation with lots of room for more bells and whistles if desired.
>
>x=. @ [
>
>y=. @ ]
>
>focus=. (3&{::) y
>
>addrs=. (2&{::) y
>
>crumbs=. (1&{::) y
>
>stack=. (0&{::) y
>
>
>zip=. '';'';'';<
>
>unzip=. focus @: (zout ^: (#@crumbs))
>
>
>zin=. (stack) ; (crumbs , <@focus) ; (addrs , 
>zout=. (stack) ; (}:@crumbs) ; (}:@addrs) ; <@(0 (([:*@L. _1{::crumbs)
>
>zam=. 
>zap=. (@ focus)(<@:)(`((3})`]))(`:6) NB. apply
>
>zpush=. (stack , <@focus) ; (crumbs) ; (addrs) ; (<@focus) NB. push focus
>in temp stack
>
>zpop=. (}:@stack) ; (crumbs) ; (addrs) ; <@(_1{::stack) NB. pop from temp
>stack
>
>zswap=. (}:@stack,<@focus) ; (crumbs) ; (addrs) ; <@(_1{::stack) NB. swap
>focus and top of temp stack
>
>
>]T=. (i.3 3);(11;22;<(_1;i.5));(<'AAA';<'BBB';'CCC')
>
>┌─┬──┬───┐
>
>│0 1 2│┌──┬──┬──┐│┌───┬─┐│
>
>│3 4 5││11│22│┌──┬─┐│││AAA│┌───┬───┐││
>
>│6 7 8││ │ ││_1│0 1 2 3 4 ││BBB│CCC│││
>
>│ ││ │ │└──┴─┘│││ │└───┴───┘││
>
>│ │└──┴──┴──┘│└───┴─┘│
>
>└─┴──┴───┘
>
>NB. zip tree
>
>zip T
>
>┌┬┬┬──┐
>
>┌─┬──┬───┐│
>
>│0 1 2│┌──┬──┬──┐│┌───┬─┐││
>
>│3 4 5││11│22│┌──┬─┐│││AAA│┌───┬───┐│││
>
>│6 7 8││ │ ││_1│0 1 2 3 4 ││BBB│CCC
>
>│ ││ │ │└──┴─┘│││ │└───┴───┘│││
>
>│ │└──┴──┴──┘│└───┴─┘││
>
>└─┴──┴───┘│
>
>└┴┴┴──┘
>
>NB. Change 'CCC' to 'DDD'
>
>unzip 'DDD' zam _1 zin _1 zin _1 zin zip T
>
>┌─┬──┬───┐
>
>│0 1 2│┌──┬──┬──┐│┌───┬─┐│
>
>│3 4 5││11│22│┌──┬─┐│││AAA│┌───┬───┐││
>
>│6 7 8││ │ ││_1│0 1 2 3 4 ││BBB│DDD│││
>
>│ ││ │ │└──┴─┘│││ │└───┴───┘││
>
>│ │└──┴──┴──┘│└───┴─┘│
>
>└─┴──┴───┘
>
>NB. Copy the third sub-tree down into the second
>
>unzip zpop _1 zin (,&a:) zap 2 zin 1 zin zout zpush 2 zin zip T
>
>┌─┬──┬───┐
>
>│0 1 2│┌──┬──┬──┐│┌───┬─┐│
>
>│3 4 5││11│22│┌──┬─┬───┐│││AAA│┌───┬───┐││
>
>│6 7 8││ │ ││_1│0 1 2 3 4│┌───┬─┐ ││BBB│CCC│││
>
>│ ││ │ ││ │ ││AAA│┌───┬───┐│ │└───┴───┘││
>
>│ ││ │ ││ │ ││ ││BBB│CCC│└───┴─┘│
>
>│ ││ │ ││ │ ││ │└───┴───┘││

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-09 Thread &#x27;Bo Jacoby&#x27; via Programming
Note that ordinal fractions also allows for trees with arrays on their leaves, 
and arrays with trees as array elements.
- Bo. 



Den 9:25 tirsdag den 9. september 2014 skrev Raul Miller 
:
 

>
>
>I've worked with a representation sort of like that, but [in my
>opinion] considerably more efficient and flexible.
>
>I'll model the two main routines here:
>
>ssdir=:3 :0
>   assert. 1=#$y
>   (}:,.2 -~/\])I.(={.)(,{.)y
>)
>
>ssndx=:4 :0
>   assert. 1=#$y
>   assert. 2=#$x
>   assert. 2={:$x
>   (;<@(+i.)/"1 x){y
>)
>
>Example use:
>
>   ssdir ' this is a test'
>0 5
>5 3
>8 2
>10 5
>
>   ex=: ' this is a test'
>   ((0 3{ssdir) ssndx ]) ex
>this test
>
>In other words, ssndx was analogous to { in design.
>
>Other notes:
>
>(0) the 'ss' part stood for Segmented String.
>
>(1) This was something like 20 years ago, using APL.
>
>(2) we had compiled APL back then, for a rank 0 subset of APL (and
>with type inference within that mini language - anything which
>constrained a type was equivalent to a type declaration), I think our
>first implementations of this code were using that compiled APL
>mechanism (but then I think it was redone in assembly language - I"m a
>bit foggy on the details at this point, but I do remember that
>performance was decent).
>
>(3) There was an additional constraint on the code, in the final
>version, such that only type character was supported. We were mostly
>interested in working with text (we were building search engines and
>related stuff ... Google's emphasis on map-reduce algorithms seems
>like a rather straightforward and obvious development from my
>perspective). But it's easy enough to build another one (not quite as
>fast as the hand assembled version) to work on other types.
>
>[Actually, I'll have to admit that I haven't been really impressed
>with a lot of the advancement of state of the art our industry. It's
>been looking like a lot of activity but most of the work (including my
>own) just has not impressed me as being all that significant. There
>have been significant improvements, of course, but not in proportion
>to the number of people employed by the industry.]
>
>Anyways... that's just two primitives, but they are quite flexible.
>You can replace ssdir with other mechanisms in some contexts, for
>example. And you can perform operations on the underlying characters
>and then use ssndx to or straight indexing to extract it in a useful
>form. (Obviously you'll need a lot more code, but this alleviated a
>significant performance bottleneck.)
>
>Thanks,
>
>-- 
>Raul
>
>On Tue, Sep 9, 2014 at 1:13 AM, Michal D.  wrote:
>> One can imagine that it's possible for
>>
>>] x =. (<@i."0) 1+i.3
>> +-+---+-+
>> |0|0 1|0 1 2|
>> +-+---+-+
>>
>> to be laid out in memory as [0 0 1 0 1 2] with an additional vector
>> representing the starting point of each rank-1 array [0 1 3 6].  I would be
>> willing to wager a large sum that this is much more computationally
>> efficient than having a representation where each rank-1 array is floating
>> off somewhere in memory [0] [0 1] [0 1 2] with an array of pointers to them.
>>
>> Of course this representation is possible, but somewhat verbose, to do
>> manually in J (http://dl.acm.org/citation.cfm?id=804488).  That's why I'm
>> fantasizing about a language where such a representation would be closer to
>> the core of the language.
>>
>> Something like +/"1 x instead of +/&.> x (obviously there's not much
>> difference here).
>>
>> Like we've both suggested, it may be that boxing with a sufficiently
>> optimized interpreter is the solution.
>>
>> Cheers,
>>
>> Mike
>>
>> On Mon, Sep 8, 2014 at 8:10 AM, Raul Miller  wrote:
>>
>>> What does this mean "shapes extended to support ragged arrays without
>>> boxing"?
>>>
>>> K has ragged arrays without boxing, but K's concept of shape only
>>> applies to the non-ragged prefix dimensions.
>>>
>>> Meanwhile, it seems to me that the guarantee you suggest would be
>>> computationally expensive.
>>>
>>> (Not saying the ideas shouldn't be explored, but I suspect what you
>>> are really after is a more efficient boxing implementation and that
>>> will lead in an entirely different direction.)
>>>
>>> Thanks,
>>>
>>> --
>>> Raul
>>>
>>>
>>> On Mon, Sep 8, 2014 at 11:01 AM, Michal D. 
>>> wrote:
>>> > Thanks Pascal, that's a nice formulation for the 2-level deep case.  It
>>> > breaks down of course for deeper nesting but could serve as a base.
>>> >
>>> > ([:|. $ ;~ $ each) ((i.2 3);(,0)) ; (i. 2 3)
>>> > +-+---+
>>> > |2|+-+---+|
>>> > | ||2|2 3||
>>> > | |+-+---+|
>>> > +-+---+
>>> >
>>> > There's no specific problem I'm trying to solve directly in J at the
>>> > moment.  It's more of a language design problem.  My interest in this is
>>> a
>>> > J like language, but with shapes extended to support ragged arrays
>>> without
>>> > boxing.  Failing that, we could have some optimization guarantees like
>>> 'an
>>> > array of boxes containing equal rank values are allocated contiguously'

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-09 Thread &#x27;Bo Jacoby&#x27; via Programming
I actually met Trenchard More back in the 1990s and we discussed his array 
theory and my ordinal fraction theory. It was a very pleasant meeting. 
- Bo.



Den 4:48 onsdag den 10. september 2014 skrev Raul Miller 
:
 

>
>
>Just use http://kx.com/software-download.php if that is what you want?
>
>Thanks,
>
>-- 
>Raul
>
>On Tue, Sep 9, 2014 at 10:39 PM, Michal D.  wrote:
>> I meant that +/"1 in our fantasy language would be the equivalent of +/&.>
>> in J.
>>
>> Cheers,
>>
>> Mike
>>
>> On Tue, Sep 9, 2014 at 8:15 AM, Linda Alvord 
>> wrote:
>>
>>> I thought Michal was indicating at the end of his message that these were
>>> the same.
>>>
>>> >Something like +/"1 x instead of +/&.> x (obviously there's not much
>>> >difference here).
>>>
>>> Linda
>>>
>>> -Original Message-
>>> From: programming-boun...@forums.jsoftware.com [mailto:
>>> programming-boun...@forums.jsoftware.com] On Behalf Of Michal D.
>>> Sent: Tuesday, September 09, 2014 1:14 AM
>>> To: programm...@jsoftware.com
>>> Subject: Re: [Jprogramming] Ragged Array Shapes are Trees
>>>
>>> One can imagine that it's possible for
>>>
>>>] x =. (<@i."0) 1+i.3
>>> +-+---+-+
>>> |0|0 1|0 1 2|
>>> +-+---+-+
>>>
>>> to be laid out in memory as [0 0 1 0 1 2] with an additional vector
>>> representing the starting point of each rank-1 array [0 1 3 6].  I would be
>>> willing to wager a large sum that this is much more computationally
>>> efficient than having a representation where each rank-1 array is floating
>>> off somewhere in memory [0] [0 1] [0 1 2] with an array of pointers to
>>> them.
>>>
>>> Of course this representation is possible, but somewhat verbose, to do
>>> manually in J (http://dl.acm.org/citation.cfm?id=804488).  That's why I'm
>>> fantasizing about a language where such a representation would be closer to
>>> the core of the language.
>>>
>>> Something like +/"1 x instead of +/&.> x (obviously there's not much
>>> difference here).
>>>
>>> Like we've both suggested, it may be that boxing with a sufficiently
>>> optimized interpreter is the solution.
>>>
>>> Cheers,
>>>
>>> Mike
>>>
>>> On Mon, Sep 8, 2014 at 8:10 AM, Raul Miller  wrote:
>>>
>>> > What does this mean "shapes extended to support ragged arrays without
>>> > boxing"?
>>> >
>>> > K has ragged arrays without boxing, but K's concept of shape only
>>> > applies to the non-ragged prefix dimensions.
>>> >
>>> > Meanwhile, it seems to me that the guarantee you suggest would be
>>> > computationally expensive.
>>> >
>>> > (Not saying the ideas shouldn't be explored, but I suspect what you
>>> > are really after is a more efficient boxing implementation and that
>>> > will lead in an entirely different direction.)
>>> >
>>> > Thanks,
>>> >
>>> > --
>>> > Raul
>>> >
>>> >
>>> > On Mon, Sep 8, 2014 at 11:01 AM, Michal D. 
>>> > wrote:
>>> > > Thanks Pascal, that's a nice formulation for the 2-level deep case.  It
>>> > > breaks down of course for deeper nesting but could serve as a base.
>>> > >
>>> > > ([:|. $ ;~ $ each) ((i.2 3);(,0)) ; (i. 2 3)
>>> > > +-+---+
>>> > > |2|+-+---+|
>>> > > | ||2|2 3||
>>> > > | |+-+---+|
>>> > > +-+---+
>>> > >
>>> > > There's no specific problem I'm trying to solve directly in J at the
>>> > > moment.  It's more of a language design problem.  My interest in this
>>> is
>>> > a
>>> > > J like language, but with shapes extended to support ragged arrays
>>> > without
>>> > > boxing.  Failing that, we could have some optimization guarantees like
>>> > 'an
>>> > > array of boxes containing equal rank values are allocated
>>> contiguously'.
>>> > >
>>> > > Cheers,
>>> > >
>>> > > Mike
>>> > >
>>> > >
>>> > >
>>> > > On Sat, Sep 6, 2014 at 9:28 AM, 'Pascal Jasmin' via Programming <
>>> > > programm...@jsoftware.com> wrote:
>>> > >
>>> > >> Hi Michal,
>>> > >>
>>> > >> maybe this is an interesting representation for what you want?
>>> > >>
>>> > >>([:|. $ ;~ $ each) (i. 2 3) ; (,0) ; 0 1
>>> > >> ┌─┬─┐
>>> > >> │3│┌───┬─┬─┐│
>>> > >> │ ││2 3│1│2││
>>> > >> │ │└───┴─┴─┘│
>>> > >> └─┴─┘
>>> > >>
>>> > >>
>>> > >>
>>> > >> - Original Message -
>>> > >> From: Michal D. 
>>> > >> To: programm...@jsoftware.com
>>> > >> Cc:
>>> > >> Sent: Saturday, September 6, 2014 12:06 PM
>>> > >> Subject: [Jprogramming] Ragged Array Shapes are Trees
>>> > >>
>>> > >> I just came to the realization that ragged array shapes, regardless of
>>> > how
>>> > >> you want to represent them, are trees.  I would be interested in any
>>> > >> references to prior exploration of this idea.
>>> > >>
>>> > >> Some example data (boxes are used to display ragged arrays, but
>>> > otherwise
>>> > >> have no semantic meaning):
>>> > >>
>>> > >>] A =. i. 2 3
>>> > >> 0 1 2
>>> > >> 3 4 5
>>> > >>] B =. (< @ i."0) 1+i.2
>>> > >> +-+---+
>>> > >> |0|0 1|
>>> > >> +-+---+
>>> > >>] C =. A ; B
>>> > >> +-+-+---+
>>> > >> |0 1 2|0|0 1|
>>> > >> |3 4 5| |   |
>>> > >> +-+-+---+
>>> > >>] D =. A ; < B
>>> > >> +-+--

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-11 Thread &#x27;Bo Jacoby&#x27; via Programming
Thanks, Dan and Thomas, for asking. I do not know the answers to Thomas' 
questions. Everything about ordinal fractions is contained in this text:
https://www.dropbox.com/s/o23cz6aao6gpanx/pluk.of?dl=0
It is an ordinal fraction database. The file is actually a turbo pascal 
program, because everything else but the program is marked as comments. I have 
not managed to translate it into J. (I have no routine in handling text files 
in J). The file is also the input file to the compiles pascal program. It 
contains a user's guide and lots of trees and arrays and database examples and 
explanations. 

Thanks! Bo.



Den 17:10 onsdag den 10. september 2014 skrev Thomas Costigliola 
:
 

>
>
>Bo, would you say that ordinal fractions are equivalent to "left lists"
>from the paper "From Trees Into Boxes"? If so, then J already addresses the
>nodes of a tree in that manner through {::, with the slight modification
>that data in a node can be an array of arbitrary shape so each step down
>the tree needs to be boxed to separate them. If not, then could you
>elaborate on the idea and how it fits into J a bit more?
>
>
>On Wed, Sep 10, 2014 at 10:44 AM, Dan Bron  wrote:
>
>> I would be interested to see a model of
>> arrays-and-trees-as-ordinal-fractions in J.  With such things as indexing,
>> catenation, etc.
>>
>> -Dan
>>
>> - Original Message -------
>>
>> Subject: Re: [Jprogramming] Ragged Array Shapes are Trees
>>From: "'Bo Jacoby' via Programming" 
>>Date: Tue, 9 Sep 2014 12:41:14 +0100
>>  To: "programm...@jsoftware.com" 
>>
>> Note that ordinal fractions also allows for trees with arrays on their
>> leaves, and arrays with trees as array elements.
>> - Bo.
>>
>>
>>
>> Den 9:25 tirsdag den 9. september 2014 skrev Raul Miller
>> :
>>
>>
>> >
>> >
>> >I've worked with a representation sort of like that, but [in my
>> >opinion] considerably more efficient and flexible.
>> >
>> >I'll model the two main routines here:
>> >
>> >ssdir=:3 :0
>> >   assert. 1=#$y
>> >   (}:,.2 -~/\])I.(={.)(,{.)y
>> >)
>> >
>> >ssndx=:4 :0
>> >   assert. 1=#$y
>> >   assert. 2=#$x
>> >   assert. 2={:$x
>> >   (;<@(+i.)/"1 x){y
>> >)
>> >
>> >Example use:
>> >
>> >   ssdir ' this is a test'
>> >0 5
>> >5 3
>> >8 2
>> >10 5
>> >
>> >   ex=: ' this is a test'
>> >   ((0 3{ssdir) ssndx ]) ex
>> >this test
>> >
>> >In other words, ssndx was analogous to { in design.
>> >
>> >Other notes:
>> >
>> >(0) the 'ss' part stood for Segmented String.
>> >
>> >(1) This was something like 20 years ago, using APL.
>> >
>> >(2) we had compiled APL back then, for a rank 0 subset of APL (and
>> >with type inference within that mini language - anything which
>> >constrained a type was equivalent to a type declaration), I think our
>> >first implementations of this code were using that compiled APL
>> >mechanism (but then I think it was redone in assembly language - I"m a
>> >bit foggy on the details at this point, but I do remember that
>> >performance was decent).
>> >
>> >(3) There was an additional constraint on the code, in the final
>> >version, such that only type character was supported. We were mostly
>> >interested in working with text (we were building search engines and
>> >related stuff ... Google's emphasis on map-reduce algorithms seems
>> >like a rather straightforward and obvious development from my
>> >perspective). But it's easy enough to build another one (not quite as
>> >fast as the hand assembled version) to work on other types.
>> >
>> >[Actually, I'll have to admit that I haven't been really impressed
>> >with a lot of the advancement of state of the art our industry. It's
>> >been looking like a lot of activity but most of the work (including my
>> >own) just has not impressed me as being all that significant. There
>> >have been significant improvements, of course, but not in proportion
>> >to the number of people employed by the industry.]
>> >
>> >Anyways... that's just two primitives, but they are quite flexible.
>> >You can replace ssdir with other mechanisms in some contexts, for
>> >example. And you can perform o

[Jprogramming] orthogonalizing a matrix

2014-09-15 Thread &#x27;Bo Jacoby&#x27; via Programming
I managed to ortogonalize a 10 10 - matrix like this:

   f=.[:(%+./)(]*[:+/[*[)-[*[:+/*
   orto =. 3 : 0
a=.,:{.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
a=.a,{.y=.({:a)f"1}.y
)
   orto(!/~)i.10
  1   1   1   11   1   1   1   1  1
 _9  _7  _5  _3   _1   1   3   5   7  9
  6   2  _1  _3   _4  _4  _3  _1   2  6
_42  14  35  31   12 _12 _31 _35 _14 42
 18 _22 _17   3   18  18   3 _17 _22 18
 _6  14  _1 _11   _6   6  11   1 _14  6
  3 _11  10   6   _8  _8   6  10 _11  3
 _9  47 _86  42   56 _56 _42  86 _47  9
  1  _7  20 _28   14  14 _28  20  _7  1
 _1   9 _36  84 _126 126 _84  36  _9  1


How can the program orto be made less embarrassing?

Thank you!


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


Re: [Jprogramming] orthogonalizing a matrix

2014-09-16 Thread &#x27;Bo Jacoby&#x27; via Programming
Thanks Arie Groeneveld! Your solution is impressive and not embarassing. I will 
spend some time deciphering it. Bo.



Den 10:46 tirsdag den 16. september 2014 skrev Aai :
 

>
>
>I'm not sure if this is less embarrassing, but here's an power iterator 
>solution:
>
>0{::([ ((,{.);]) {:@[ f"1 }.@])&>/^:(<:@#`(,:@{.;])) !/~i.10
>
>
>
>On 16-09-14 08:56, 'Bo Jacoby' via Programming wrote:
>> I managed to ortogonalize a 10 10 - matrix like this:
>>
>> f=.[:(%+./)(]*[:+/[*[)-[*[:+/*
>> orto =. 3 : 0
>> a=.,:{.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> a=.a,{.y=.({:a)f"1}.y
>> )
>> orto(!/~)i.10
>>1   1   1   11   1   1   1   1  1
>>   _9  _7  _5  _3   _1   1   3   5   7  9
>>6   2  _1  _3   _4  _4  _3  _1   2  6
>> _42  14  35  31   12 _12 _31 _35 _14 42
>>   18 _22 _17   3   18  18   3 _17 _22 18
>>   _6  14  _1 _11   _6   6  11   1 _14  6
>>3 _11  10   6   _8  _8   6  10 _11  3
>>   _9  47 _86  42   56 _56 _42  86 _47  9
>>1  _7  20 _28   14  14 _28  20  _7  1
>>   _1   9 _36  84 _126 126 _84  36  _9  1
>>
>>
>> How can the program orto be made less embarrassing?
>>
>> Thank you!
>>
>>
>> Bo.
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
>-- 
>Met vriendelijke groet,
>@@i = Arie Groeneveld
>
>--
>For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Beginner question

2014-09-26 Thread &#x27;Bo Jacoby&#x27; via Programming
Adding 'Up' or 'Left' or 'Back' to 'Rotate' is not really helpful. Examples 
does the trick.

   1|.1 2 3
2 3 1
   _1|.1 2 3
3 1 2
   1|.i.3 3
3 4 5
6 7 8
0 1 2


Den fre 26/9/14 skrev Don Guinn :

 Emne: Re: [Jprogramming] Beginner question
 Til: "Programming forum" 
 Dato: fredag 26. september 2014 00.24
 
 Rotate (Left/Up)
 
 On Thu, Sep 25, 2014 at 4:21
 PM, Henry Rich 
 wrote:
 
 > Funny, but
 'rotate up' feels like 'rotate toward higher
 numbers' to me, i.
 > e. rotate
 right.
 >
 > Henry
 Rich
 >
 > On 9/25/2014
 6:16 PM, Raul Miller wrote:
 >
 >> Would "Rotate Up" work for
 you?
 >>
 >>
 Thanks,
 >>
 >> 
 --
 > 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


Re: [Jprogramming] Fwd: Plotting magnitudes of complex numbers in J

2014-10-03 Thread &#x27;Bo Jacoby&#x27; via Programming
Note that (plot 5 13) looks different from (plot 5j0 13j0) even if they are 
equal: (5 13 -: 5j0 13j0). The error message is however a bug. 

 plot %:@:(* +)3j4 12j5
|domain error: glcmds
|   glcmds buf
Venlig hilsen, Bo.



Den 2:50 lørdag den 4. oktober 2014 skrev Henry Rich :
 

>
>
>Yes.  Complex numbers plot differently (they are assumed to be x,y pairs)
>
>If you take the real part, using 9&o., it should work.  Better to use norm2.
>
>Henry Rich
>
>On 10/3/2014 7:24 PM, Vijay Lulla wrote:
>> When I tried it I got the following:
>>
>>  datatype norm1 3j4 12j5
>>
>> complex
>>
>>  datatype norm2 3j4 12j5
>>
>> floating
>>
>>
>> Maybe this could be the issue?
>>
>>
>> On Fri, Oct 3, 2014 at 7:16 PM, bill lam  wrote:
>>
>>> I forwarded this to J forum because I have no real knowledge of plot.
>>> -- Forwarded message --
>>> From: "Andrey Paramonov" 
>>> Date: Oct 4, 2014 7:07 AM
>>> Subject: Plotting magnitudes of complex numbers in J
>>> To: 
>>> Cc:
>>>
>>> Hi Bill,
>>>
>>> For some reason my message to programm...@jsoftware.com doesn't go
>>> through, so I thought I can shoot you an email with some strange
>>> behaviour (bug?) I see in the plot function. Here is the snippet that
>>> highlights the problem
>>>
>>> norm1=: %:@:(* +)
>>> norm2=: |
>>> norm1 3j4 12j5
>>> 5 13
>>> norm2 3j4 12j5
>>> 5 13
>>> load 'plot'
>>> plot norm2 3j4 12j5 NB. works
>>> plot norm1 3j4 12j5 NB. does NOT work
>>>
>>> I thought you might find it interesting.
>>>
>>> Thank you,
>>> Andrey
>>>
>>> P.S. I'm using j64-802.
>>> --
>>> 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
>
>
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] count of consecutive 1s

2014-10-25 Thread &#x27;Bo Jacoby&#x27; via Programming

Isn't
   ([*[+])/\. 1 0 1 1 1 0 1
the same as 

   ([*+)/\. 1 0 1 1 1 0 1
?



Den 21:10 torsdag den 23. oktober 2014 skrev Joe Bogner :
 

>
>
>This can also answer the question in a backwards, slower sense:
>
>([*[+])/\. 1 0 1 1 1 0 1
>
>
>1 0 3 2 1 0 1
>
>
>
>On Wed, Oct 22, 2014 at 2:12 PM, R.E. Boss  wrote:
>
>>
>>}.;([:<+/\);.1[ 0,x
>> 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2
>>
>>
>> R.E. Boss
>>
>> (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )
>>
>>
>> > -Original Message-
>> > From: programming-boun...@forums.jsoftware.com [mailto:programming-
>> > boun...@forums.jsoftware.com] On Behalf Of Roger Hui
>> > Sent: woensdag 22 oktober 2014 19:25
>> > To: Programming forum
>> > Subject: Re: [Jprogramming] count of consecutive 1s
>> >
>> >x
>> > 0 1 1 1 0 1 1 1 0 1 1 0 0 1 0 0 0 0 1 1
>> >s->./\(-.x)*s=.+/\x
>> > 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2
>> >
>> >
>> >
>> > On Wed, Oct 22, 2014 at 10:21 AM, Roger Hui 
>> > wrote:
>> >
>> > > You can probably do better than the following, but it'd be useful as a
>> > > result checker:
>> > >
>> > >] x=: 0<20 ?@$ 3
>> > > 0 1 1 1 0 1 1 1 0 1 1 0 0 1 0 0 0 0 1 1
>> > >}. ; +/\&.> <;.1 ] 0,x
>> > > 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2
>> > >
>> > >
>> > >
>> > >
>> > > On Wed, Oct 22, 2014 at 10:10 AM, Joe Bogner 
>> > wrote:
>> > >
>> > >> This is probably easy but I can't figure it out. How can I count the
>> > >> number
>> > >> of consecutive 1s?
>> > >>
>> > >> Another way to think about it is a running sum that resets upon
>> hitting
>> a
>> > >> zero
>> > >>
>> > >> input=:1 0 1 1 1 1 0 1
>> > >>
>> > >> expected=: 1 0 1 2 3 4 0 1
>> > >> --
>> > >> 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
>>
>--
>For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Wrong numbers in normal distribution?

2015-03-11 Thread &#x27;Bo Jacoby&#x27; via Programming
The probabilities are effectively zero.  

 Den 3:42 torsdag den 12. marts 2015 skrev Ryan :
   
 

 'normalcdf' gives different a result than R and Python for y < -7

In J:

  load'stats'
  ([,:normalcdf) - i._10
          _9          _8          _7          _6        _5        _4  
      _3        _2      _1  0
_2.22045e_16 1.38778e_15 1.27998e_12 9.86588e_10 2.86652e_7 3.16712e_5 
0.0013499 0.0227501 0.158655 0.5

In R:

> cat(pnorm(-9:0))
1.128588e-19 6.220961e-16 1.279813e-12 9.865876e-10 2.866516e-07 
3.167124e-05 0.001349898 0.02275013 0.1586553 0.5

Does anyone know why?

thanks,
Ryan


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

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


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

[Jprogramming] simplify

2015-06-25 Thread &#x27;Bo Jacoby&#x27; via Programming
NB. If you have got a bunch of numbers      ]n=.?20#10035 32 66 37 94 56 44 30 
25 70 27 68 49 92 96 79 74 99 72 22NB. and you want to simplify, then take the 
mean value
   1 simplify n58.35
NB. or take the mean value minus (or plus) the standard deviation   3": 2 
simplify n 33 84NB. or take three numbers having the same mean value and the 
same standard deviation and the same skewness as the original numbers
   3": 3 simplify n
 28 56 90NB. and so on:
   3": 4 simplify n
 26 46 68 94   3": 5 simplify n 25 37 60 75 96   1 simplify 5 simplify n
58.35NB. I think this simplify verb is cute and perhaps even useful, so I am 
sharing it with you.
simplify=. 4 : 0
y=.x*}.(%{.)+/y^/i.>:x
x=.1
for.y do.x=.((-/x*(‪#‎x‬){.y)%#x),x end.
-|.>{:p.x
)NB. If you can simplify the programming, the please let me know.
ThanksBo
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] simplify

2015-06-25 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you Kip.
The 5&simplify function is equally sensitive to all observations while the 
quartiles are highly sensititive to a few observations. 

The 5&simplify function is analytic while the quartiles are not analytic 
functions. 




 Den 12:19 torsdag den 25. juni 2015 skrev Kip Murray 
:
   
 

 You may want to try Tukey's five number, seven member, etc summaries,
appropriate for data from distributions not known to be normal. See

https://en.m.wikipedia.org/wiki/Five-number_summary

--Kip Murray

On Thursday, June 25, 2015, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

> NB. If you have got a bunch of numbers      ]n=.?20#10035 32 66 37 94 56
> 44 30 25 70 27 68 49 92 96 79 74 99 72 22NB. and you want to simplify, then
> take the mean value
>    1 simplify n58.35
> NB. or take the mean value minus (or plus) the standard deviation  3": 2
> simplify n 33 84NB. or take three numbers having the same mean value and
> the same standard deviation and the same skewness as the original numbers
>    3": 3 simplify n
>  28 56 90NB. and so on:
>    3": 4 simplify n
>  26 46 68 94  3": 5 simplify n 25 37 60 75 96  1 simplify 5 simplify n
> 58.35NB. I think this simplify verb is cute and perhaps even useful, so I
> am sharing it with you.
> simplify=. 4 : 0
> y=.x*}.(%{.)+/y^/i.>:x
> x=.1
> for.y do.x=.((-/x*(‪#‎x‬){.y)%#x),x end.
> -|.>{:p.x
> )NB. If you can simplify the programming, the please let me know.
> ThanksBo
> --
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
Sent from Gmail Mobile


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

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

Re: [Jprogramming] simplify

2015-06-26 Thread &#x27;Bo Jacoby&#x27; via Programming
Explanation: The vector 'A simplify B' has the same A moments as the vector 
B.Examples:   1 simplify 0 21   2 simplify 0 20 2   3 simplify 0 2_0.224745 1 
2.22474   2 simplify 3 simplify 0 20 2   1 simplify 3 simplify 0 21
 



 Den 0:04 fredag den 26. juni 2015 skrev Kip Murray 
:
   
 

  1 X

 2 X X

 3

 4 X

 5

 6 X


 1 X

 2

 3 X

 4

 5 X

 6


 1
    X
 2 X

 3

 4

 5 X

 6


Above I have attempted three histograms.  The first shows the data set 1 2
2 4 6 which has mean 3 and standard deviation 2, median 2 and fourths (not
quartiles) 1.5 and 5 .  The second histogram shows the mean and the mean
plus or minus a standard deviation, and the third histogram shows the
median and fourths.  (The fourths are respectively the median of the
numbers below the median, and the median of the numbers above the median.)

--Kip Murray


On Thursday, June 25, 2015, Devon McCormick  wrote:

> I put together this J based on the "fivenum" routine in R mentioned in the
> Wikipedia link:
>
> fivenum=: 3 : 0
>    if. 0=#y=. /:~y do. 5#_.
>    else. n4=. -:<.-:3+#y
>        d=. <:1,n4,(-:>:#y),(n4-~>:#y),#y
>        -:(y{~<.d)+y{~>.d
>    end.
> )
>
> It returns the minimum, the quartile points, and the maximum of a series.
> The first branch of the "if" roughly replicates some of the R function's
> NA-handling.
>
> On Thu, Jun 25, 2015 at 10:14 AM, David Lambert  >
> wrote:
>
> > Is simplify supposed to report the i.x moments of the data?  Would be
> > useful.
> > When I removed the question marks from simplify to make valid j
> >    1 simplify DATA NB. does report the mean
> > Otherwise I haven't made sense of the results for the verb I created.
> >
> >    datatype N
> > integer
> >
> >    3 simplify N
> > _951.236j1533.8 _951.236j_1533.8 2658.39
> >
> >  Date: Thu, 25 Jun 2015 08:39:51 + (UTC)
> >> From: "'Bo Jacoby' via Programming" >
> >> To: Programming Forum>
> >> Subject: [Jprogramming] simplify
> >> Message-ID:
> >>        <1806252176.1379402.1435221591208.javamail.ya...@mail.yahoo.com
> >
> >> Content-Type: text/plain; charset=UTF-8
> >>
> >> NB.?If you have got a bunch of numbers? ? ? ]n=.?20#10035 32 66 37 94 56
> >> 44 30 25 70 27 68 49 92 96 79 74 99 72 22NB. and you want to simplify,
> then
> >> take the mean value
> >>
> >
> >  
> >>
> >
> >  )NB.?If you can simplify the programming, the please let me know.
> >> ThanksBo
> >>
> >
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
>
>
> --
> Devon McCormick, CFA
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>


-- 
Sent from Gmail Mobile
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] simplify

2015-06-26 Thread &#x27;Bo Jacoby&#x27; via Programming
   datatype 1 2 3 7integer   datatype 2 simplify 1 2 3 7floating   datatype 3 
simplify 1 2 3 7complex   (2&simplify=[:2&simplify 3&simplify) 1 2 3 71 1A 
correct result may be non-real! 
 



 Den 9:53 fredag den 26. juni 2015 skrev 'Bo Jacoby' via Programming 
:
   
 

 Explanation: The vector 'A simplify B' has the same A moments as the vector 
B.Examples:   1 simplify 0 21   2 simplify 0 20 2   3 simplify 0 2_0.224745 1 
2.22474   2 simplify 3 simplify 0 20 2   1 simplify 3 simplify 0 21
 



    Den 0:04 fredag den 26. juni 2015 skrev Kip Murray :
  
 

  1 X

 2 X X

 3

 4 X

 5

 6 X


 1 X

 2

 3 X

 4

 5 X

 6


 1
    X
 2 X

 3

 4

 5 X

 6


Above I have attempted three histograms.  The first shows the data set 1 2
2 4 6 which has mean 3 and standard deviation 2, median 2 and fourths (not
quartiles) 1.5 and 5 .  The second histogram shows the mean and the mean
plus or minus a standard deviation, and the third histogram shows the
median and fourths.  (The fourths are respectively the median of the
numbers below the median, and the median of the numbers above the median.)

--Kip Murray


On Thursday, June 25, 2015, Devon McCormick  wrote:

> I put together this J based on the "fivenum" routine in R mentioned in the
> Wikipedia link:
>
> fivenum=: 3 : 0
>    if. 0=#y=. /:~y do. 5#_.
>    else. n4=. -:<.-:3+#y
>        d=. <:1,n4,(-:>:#y),(n4-~>:#y),#y
>        -:(y{~<.d)+y{~>.d
>    end.
> )
>
> It returns the minimum, the quartile points, and the maximum of a series.
> The first branch of the "if" roughly replicates some of the R function's
> NA-handling.
>
> On Thu, Jun 25, 2015 at 10:14 AM, David Lambert  >
> wrote:
>
> > Is simplify supposed to report the i.x moments of the data?  Would be
> > useful.
> > When I removed the question marks from simplify to make valid j
> >    1 simplify DATA NB. does report the mean
> > Otherwise I haven't made sense of the results for the verb I created.
> >
> >    datatype N
> > integer
> >
> >    3 simplify N
> > _951.236j1533.8 _951.236j_1533.8 2658.39
> >
> >  Date: Thu, 25 Jun 2015 08:39:51 + (UTC)
> >> From: "'Bo Jacoby' via Programming" >
> >> To: Programming Forum>
> >> Subject: [Jprogramming] simplify
> >> Message-ID:
> >>        <1806252176.1379402.1435221591208.javamail.ya...@mail.yahoo.com
> >
> >> Content-Type: text/plain; charset=UTF-8
> >>
> >> NB.?If you have got a bunch of numbers? ? ? ]n=.?20#10035 32 66 37 94 56
> >> 44 30 25 70 27 68 49 92 96 79 74 99 72 22NB. and you want to simplify,
> then
> >> take the mean value
> >>
> >
> >  
> >>
> >
> >  )NB.?If you can simplify the programming, the please let me know.
> >> ThanksBo
> >>
> >
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
>
>
> --
> Devon McCormick, CFA
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>


-- 
Sent from Gmail Mobile
--
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

Re: [Jprogramming] editing a verb definition

2015-06-27 Thread &#x27;Bo Jacoby&#x27; via Programming
Highlight the corrected program definition and type ctrl-E to execute the 
highlighted text. 


 Den 5:51 søndag den 28. juni 2015 skrev Raul Miller 
:
   
 

 Oh, yes - my control-N comment assumed he was using jqt. If he was
using JHS it's different.

Thanks,

-- 
Raul


On Sat, Jun 27, 2015 at 11:28 PM, Joe Bogner  wrote:
> For throwaway definitions, the JHS (web-based ide) scratch window is good
> too.
> On Jun 27, 2015 11:20 PM, "Raul Miller"  wrote:
>
>> For multi-line definitions like this, you should be putting your
>> script in a file.
>>
>> Hit control-N to get a blank editor window.
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Sat, Jun 27, 2015 at 10:24 PM, Daniel Roe  wrote:
>> > I'm just learning J so this is a bit of a newbie question.
>> > 1) I open up the J session window
>> > 2) I type in a definition of a verb from the Learning J document -
>> Chapter 12...
>> >
>> > dog =: 3 : 0
>> > if. y>90 do. 'too hot'
>> > elseif. y<30 do. 'too cold'
>> > elseif. 1 do. 'OK'
>> > end.
>> > )
>> > It's the porridge - too hot - too cold - example - I called it dog
>> > Now I want to go back in and change the parameters a bit - for example I
>> want to make too cold be < 40 not 30.3) I put the cursor in the definition
>> and change the 30 to a 40
>> >
>> > 4) With the cursor I select the entire definition and then copy it with
>> a CTRL-C
>> >
>> > 5) I hit he enter key until I get the waiting for input cursor down
>> below everything
>> > 6) I paste in the modified definition with a CTRL-V and hit enter
>> > 7) I get a syntax error message.
>> > I can't believe that one must re-type the entire definition just to make
>> a change. What am I doing wrong?
>> > Dan
>> >
>> >
>> > --
>> > 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
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] simplify

2015-06-28 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you Jose Mario Quintana, for your impressive enthusiasm!
The summary is:
   simplify4 : 0x=.1[y=.x*}.(%{.)+/y^/i.>:xfor.y do.x=.((-/x*(#x){.y)%#x),x 
end.-|.>{:p.x)
   4 simplify 0 0 0 1 NB. no simplification0 0 0 1   3 simplify 0 0 0 1 NB. 
non-real result_0.0759785j0.193742 _0.0759785j_0.193742 0.901957   2 simplify 0 
0 0 1 NB. mean value (-,+) standard deviation._0.183013 0.683013   1 simplify 0 
0 0 1 NB. mean value0.25
NB. mean value and standard deviation is preserved:   2 simplify 3 simplify 0 0 
0 1 NB. mean value (-,+) standard deviation._0.183013 0.683013   1 simplify 3 
simplify 0 0 0 1 NB. mean value0.25
NB. the real part of the non-real result makes some sense   -:(++) 3 simplify 0 
0 0 1_0.0759785 _0.0759785 0.901957
NB. but it does not have the correct mean and stddev.   2 simplify -:(++) 3 
simplify 0 0 0 1_0.211003 0.711003
- Bo.




 Den 20:50 søndag den 28. juni 2015 skrev Jose Mario Quintana 
:
   
 

 Whoa! I take that back (I forgot about a third moment :).

On Sun, Jun 28, 2015 at 2:27 PM, Jose Mario Quintana <
jose.mario.quint...@gmail.com> wrote:

> You are right, in the following sense,
>
>    ys=. [ * }.@:(% {.)@:(+/)@:(] ^/ i.@:>:@:[)
>    update=. ] ,~ -/@:(] * [ {.~ #@:]) % #@:]
>
>    simple=. -@:|.@:>@:{:@:p.@:(ys update ^: (#@:[) 1:)f.
>
>    mean=. +/ % #
>    std =: mean &.: *: @: (- mean)
>
>    Y=. 1 2 3 7
>
>    (mean ; std) Y
> ┌┬───┐
> │3.25│2.27761│
> └┴───┘
>
>    ( S0=. 3 simple Y  )
> 1.6084j0.550768 1.6084j_0.550768 6.53321
>    (mean ; std) S0
> ┌┬───┐
> │3.25│2.27761│
> └┴───┘
>
> However, if complex results are allowed (and I do not see why should not
> be allowed) then the statement: " The vector 'A simplify B' has the same A
> moments as the vector B" does not provide a (full) characterization of the
> result since,
>
>    ( S1=. (3&simple + 2*(mean - 3&simple)) Y)
> 4.8916j_0.550768 4.8916j0.550768 _0.0332088
>    (mean ; std) S1
> ┌┬───┐
> │3.25│2.27761│
> └┴───┘
>
> and clearly,
>
>    S0 -: S1
> 0
>
> Yet, S0 seems to be a better result compared to S1 in following context:
>
>    (mean ; std) *: Y
> ┌─┬───┐
> │15.75│19.4084│
> └─┴───┘
>    (mean ; std) *: S0
> ┌─┬───┐
> │15.75│18.9894│
> └─┴───┘
>    (mean ; std) *: S1
> ┌─┬───┐
> │15.75│10.2303│
> └─┴───┘
>
> That is, under *: apparently, S0 as opposed to S1, preserves better the
> mean and the std, and under other some other transformations as well, for
> example,
>
>    (mean ; std) %: Y
> ┌─┬┐
> │1.698│0.605626│
> └─┴┘
>    (mean ; std) %: S0
> ┌───┬┐
> │1.70945│0.572513│
> └───┴┘
>    (mean ; std) %: S1
> ┌─┬──┐
> │1.47679j0.0607443│1.03934j_0.0863113│
> └─┴──┘
>
>    (mean ; std) ^ Y
> ┌───┬───┐
> │281.707│470.541│
> └───┴───┘
>    (mean ; std) ^ S0
> ┌───┬───┐
> │232.038│322.125│
> └───┴───┘
>    (mean ; std) ^ S1
> ┌───┬┐
> │75.9723│0j20.618│
> └───┴┘
>
>    (mean ; std) ^. Y
> ┌┬┐
> │0.934417│0.703815│
> └┴┘
>    (mean ; std) ^. S0
> ┌┬┐
> │0.979417│0.574606│
> └┴┘
>    (mean ; std) ^. S1
> ┌─┬┐
> │_0.0724338j1.0472│2.35516j_1.48176│
> └─┴┘
>
> Of course, the simplification might not work well when there is some
> variation within the range; but, even then S0 seems to make more sense than
> S1,
>
>    (mean ; std) 2 o. Y
> ┌──┬┐
> │_0.0279837│0.708947│
> └──┴┘
>    (mean ; std) 2 o. S0
> ┌────────┬─┐
> │0.294011│0.0673377│
> └┴─┘
>    (mean ; std) 2 o. S1
> ┌┬──┐
> │0.470473│0j0.276611│
> └┴──┘
>
> In any case, I find symplify quite interesting but it seems that your
> definition is incomplete.  Perhaps, A&simplify should also be required to
> be analytic?
>
>
> On Fri, Jun 26, 2015 at 4:54 AM, 'Bo Jacoby' via Programming <
> programm...@jsoftware.com> wrote:
>
>>    datatype 1 2 3 7integer  datatype 2 simplify 1 2 3 7floating
>>  datatype 3 simplify 1 2 3 7complex  (2&simplify=[:2&simplify 3&simplify)
>> 1 2 3 71 1A correct result may be non-real!
>>
>>
>>
>>
>>      Den 9:53 fredag den 26. juni 2015 skrev 'Bo Jacoby' via Programming <
>> programm...@jsoftware.com>:
>>
>>
>>
&g

Re: [Jprogramming] symbol speed

2015-07-03 Thread &#x27;Bo Jacoby&#x27; via Programming
Hello Pascal. 
I read your message with interest, but alas I understand but very little. 
Are your files ascii text files? How are they read into J? How are they 
transferred into symbols? Do you utilize the fact that the dictionary file is 
sorted? Is there a wiki where such topics are explained?
Thank you!
Bo.
 


 Den 4:45 lørdag den 4. juli 2015 skrev 'Pascal Jasmin' via Programming 
:
   
 

 it does not appear that working with lists of crcs is any faster

instead of words... ie dictionary LF data on clipboard:

 w =. 1 2 3 4 5 6 7 8 9 10 <@(] #~ [ = #@:] every)"0 _ (;: 'a i o'),  cutLF 
wdclippaste ''

above just keeps 10 letter words or less, and places them in 10 boxes

10 boxes of lists of CRCs (for each word size)

wn =. /:~@:(128!:3 every) each w

a is same as previous quoted message

>  (]#~0.8<[:(+/%#)every(((wn{::~ :: 0: <:@#)e.~128!:3)every@:;:)each) a

takes over 12 seconds.  This was faster than 1 big list of CRCs


- Original Message -
From: 'Pascal Jasmin' via Programming 
To: Programming Forum 
Cc: 
Sent: Friday, July 3, 2015 9:26 PM
Subject: [Jprogramming] symbol speed

A cool use of symbols, not obvious to me until today, is a word dictionary used 
to test if some other input is in dictionary or not.

using this list on clipboard

https://gist.githubusercontent.com/Quackmatic/512736d51d84277594f2/raw/words



words =: s: (;: 'a i o'),  cutLF wdclippaste ''  NB.(adding 1 letter words)

here is a list of gibberish sentences that contain 3 real sentences

https://gist.githubusercontent.com/anonymous/c8fb349e9ae4fcb40cb5/raw/05a1ef03626057e1b57b5bbdddc4c2373ce4b465/challenge.txt

with that new list on the clipboard

a =: (<', . ? ! : ; ') rplc~ each cutLF wdclippaste ''

the following is not terrible (3 seconds or so).  filters lines where 80% of 
words are in dictionary.

> (] #~ 0.8 < [: (+/%#) every (words e.~ s:@:;: )each)  a

Is there a way to make it faster?

I was thinking that a sparse array 2d, where first index is the letter count 
and 2nd index is crc32 and the element value is 1 if the value exists in 
dictionary and 0 otherwise could be ok.

even simpler would be a list of valid crc32 values since 60k/4B is going to 
have a very low false positive rate well suited to testing to an 80% threshold.

Would those approaches be faster?
--
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

Re: [Jprogramming] Question on E. command

2015-07-08 Thread &#x27;Bo Jacoby&#x27; via Programming
    (<,'h') E.  a0 0 0 1 0 0    (<,'dd') E.  a0 1 0 0 0 0
 


 Den 11:49 onsdag den 8. juli 2015 skrev Strale :
   
 

 Hello I am trying to learn J
and trying to make a function to tokenise strings

I have tried the E. command but I cannot have it working to search 1 char
token

ex:
  [a=. ;: 'cc dd f h gg zz'

  ┌──┬──┬─┬─┬──┬──┐

  │cc│dd│f│h│gg│zz│

  └──┴──┴─┴─┴──┴──┘


  (<'h') E.  a

    0 0 0 0 0 0


but when I search for a pattern longer as 1 char it works

  (<'dd') E.  a

  0 1 0 0 0 0


How should I use the E. to works with tokens of 1 char length ?


Thank in advance

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

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

Re: [Jprogramming] Question on E. command

2015-07-08 Thread &#x27;Bo Jacoby&#x27; via Programming
I wonder who takes away the linefeeds from my emails to programming forum. They 
are incomprehensible anyway so further destruction is not needed. :)
 


 Den 13:00 onsdag den 8. juli 2015 skrev Joe Bogner :
   
 

 Good question! That has tripped up many people (including myself)

Elaborating on both fine answers:

If you aren't sure why you need enclose the atom in a list, this might help:

Question: What are the shapes of each of the items in the list?

 $ each ;: 'cc dd f h gg zz'
┌─┬─┬─┬─┬─┬─┐
│2│2│1│1│2│2│
└─┴─┴─┴─┴─┴─┘

Question: What is the shape of a boxed atom?
  $ <'h'

(empty) -- it's not a list

Another point from NuVoc that might help:

http://www.jsoftware.com/jwiki/Vocabulary/ecapdot

"Create a Boolean array indicating starting points in y of subarrays
equal to x" -- see point above about <'h' not being a list and
therefore no subarray will equal to it



On Wed, Jul 8, 2015 at 6:04 AM, Brian Schott  wrote:
> Elaborating on Bo's fine answer and (hopefully) adding line feeds.
>
>    (<'h') E. each  a
> ┌───┬───┬─┬─┬───┬───┐
> │0 0│0 0│0│1│0 0│0 0│
> └───┴───┴─┴─┴───┴───┘
>    (<,'h') E.  a
> 0 0 0 1 0 0
>    (<,'dd') E.  a
> 0 1 0 0 0 0
>
>
>
>
> --
> (B=)
> --
> 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

Re: [Jprogramming] minor note: csv data

2015-07-15 Thread &#x27;Bo Jacoby&#x27; via Programming
WOW Raul! 


 Den 22:34 onsdag den 15. juli 2015 skrev Raul Miller 
:
   
 

 That won't work, though, for data which results from readcsv.

I was just using numeric data because that made the example easy to construct.

Thanks,

-- 
Raul


On Wed, Jul 15, 2015 at 3:46 PM, 'Pascal Jasmin' via Programming
 wrote:
> an alternative that takes the same space but keeps the data numeric
>
> (;:'a b c d'),: ,. each  <"1&.|: p:p:p:i.4 4
>
>
> - Original Message -
> From: Raul Miller 
> To: Programming forum 
> Cc:
> Sent: Wednesday, July 15, 2015 3:33 PM
> Subject: [Jprogramming] minor note: csv data
>
> I've been using ~.": a lot lately, when working with csv data (with a
> header row).
>
> Here's what that looks like:
>
>    ~.": (;:'a b c d'),]&.>p:p:p:i.4 4
> ┌┬┬┬┐
> │a  │b  │c  │d  │
> ├┼┼┼┤
> │13  │19  │43  │71  │
> │163 │193 │293 │359 │
> │463 │619 │743 │971 │
> │1091│1181│1423│1601│
> └┴┴┴┘
>
> of course, that will be mangled if you're using a proportionally
> spaced font or have other font issues. But in a good fixed width font,
> you get a more compact display than boxed.
>
> This wouldn't work right if rows of data were duplicated, but that
> would be garbage data in the contexts I've been working with. So for
> me that's a non-issue.
>
> Anyways, this might work for someone else, also...
>
> FYI,
>
> --
> Raul
> --
> 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

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

Re: [Jprogramming] [Jdatabase] A few questions

2015-07-29 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi Yoel.
You may like this analytic approach:
NB. (x simplify y) has the same x moments as y.
   simplify=.4 : 0
y=.x*}.(%{.)+/y^/i.>:x
x=.1
for.y do.x=.((-/x*(#x){.y)%#x),x end.
-|.>{:p.x
)
   7 simplify ?#~1e6
58239 235294 337754 500292 661923 765143 941999
   7 simplify 58239 235294 337754 500292 661923 765143 941999
58239 235294 337754 500292 661923 765143 941999

 


 Den 10:43 onsdag den 29. juli 2015 skrev Yoel Jacobsen 
:
   
 

 Raul,

I'm forking the discussion to the general programming forum.

I rather provide the percentile list as an argument. Explicitly, I can:

 percentiles =: dyad : '(x >.@* <:@# y){/:~y'


So:

(0.01 0.05 0.25 0.50 0.75 0.95 0.99) percentiles ?#~1e6

9910 49979 249913 499397 749931 950080 990111


But I wondered how to do it tacitly?


I would need a fork of with both the dyadic (>.@* <:@#) and the monadic
(/:~) parts. Can I combine them in a single tacit form?


Yoel






On Tue, Jul 28, 2015 at 8:09 PM Raul Miller  wrote:

> I have not been using JD, so I will leave those issues for someone
> with some relevant expertise.
>
> However, here's how I might implement percentiles in J:
>
> plabels=: 0.01 0.05 0.25 0.50 0.75 0.95 0.99
> percentiles=: ({~ plabels >.@* <:@#)@/:~
>
> Example use:
>    percentiles ?#~1e6
> 9969 50074 250161 500063 750329 950518 989874
>
> Though of course if you were already working with sorted data, you
> could eliminate the @/:~
>
> Thanks,
>
> --
> Raul
>
> On Tue, Jul 28, 2015 at 12:57 PM, Yoel Jacobsen 
> wrote:
> > Hello,
> >
> > Long list of questions, apology in advance...
> >
> > I'm playing with Jd by trying to use it as an analytical time series
> > database and have a few questions.
> >
> > Setup:
> > - Tests are running on my laptop (1.7GHz multi core CPU, 32GB RAM)
> > - O/S is 64bit Linux. J version is 8.04
> > - Single table created as follows:
> >
> > jd'createtable calls time datetime, num byte 10, provider byte 10, a
> float,
> > b float, c float'
> >
> >
> > The 'num' field is defined as byte 10 as it describes a phone number. I
> can
> > optimize using 'int' and clean the phone number in advance but its of
> less
> > importance at the moment. I may convert time to epochdt but datetime was
> > easier to play with 6!:2..
> >
> >
> > - I loaded 700M records into the table. Size on disk:
> >
> >
> > $ du -sh *
> > 5.3G a
> > 5.3G b
> > 5.3G c
> > 4.0K column_create_order.txt
> > 668M jdactive
> > 4.0K jdclass
> > 8.0K jdindex
> > 4.0K jdstate
> > 6.6G num
> > 6.6G provider
> > 5.3G time
> >
> >
> > Now, my questions:
> >
> >
> > 1. Some queries are running out of memory. Such as:
> >
> >  jd'reads min time,max time from calls'
> >
> > |Jd error: out of memory: Where: indices=:
> > /:~@:~.&.|:>,.&.>/andqueries&.>toSoP fixwhere_jdtable_ y: op:reads
> db:calls
> > user:u : jd_jd_
> >
> > | 13!:8&3 t
> >
> > Why is that? Should Jd load (map) only the 5.3GB of the 'time' field?
> >
> > 2. The following search runs out of memory:
> >
> > jd'reads count a from calls'
> >
> >
> > while this one don't:
> >
> > jd'reads count a from calls where num="012-456789'
> >
> >
> > Why is that?
> >
> >
> > 3. Is there any "server" part above running Jd  in a JHS session?
> >
> > 4. Is there any way to partition the data automatically (for instance,
> have
> > a difference folder per day)?
> >
> > 5. Is there a simple way to search between dates with the built in time
> > types (epochdt, datetime)? How about queries like - between 2 and 5 hours
> > ago? 3 days ago?
> >
> > 6. Is there a "reference" architecture for having a real time DB (in RAM)
> > and historical DB with scheduled data movements? Suppose the above size
> > reflects a week of data (35GB) and I want searchable historical db for a
> > year (35GB x 52 weeks = 1.82TB). I guess some sort of partitioning is
> > mandatory to avoid out of memory errors when searching the historical
> DB..
> >
> > 7. Can one define an aggregation verb  in J (my first would be
> percentile)?
> >
> > Thanks,
> >  Yoel
> > --
> > 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


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

Re: [Jprogramming] Understanding ^:

2015-08-02 Thread &#x27;Bo Jacoby&#x27; via Programming
   ((+])^:10) 1
1024
 (+]^:10) 1
2
Does this help?
- Bo. 


 Den 20:16 søndag den 2. august 2015 skrev Raul Miller 
:
   
 

 I think Pascal has pretty much already covered it, but these are equivalent:

  f^:5 n
  f f f f f n

And these are also equivalent:
  m f^:3 n
  m f m f m f n

Thanks,

-- 
Raul


On Sun, Aug 2, 2015 at 11:26 AM, Jon Hough  wrote:
> I'm attempting some functions that use verb power (^:) , but I'm a little 
> lost when it comes to the concept of what is getting iterated.
> For example, in pseudo code:
> function f(y){
> a = y; //cache initial value
>
> counter = 10;
> while(counter-->0){
> y = y + a;
> }
> return y;}
> In the above code, y was initially cached for later use. Trying this in tacit 
> J I did:
> f =: +]^:10
> which completely gives the wrong result. Obviosuly the above function is not 
> interesting, and I'm attempting more interesting things, but the principle is 
> the same, how can I cache the initial value for use in each iteration when 
> using ^:? Do I need to use explicit verbs instead?
> Thanks,
> Jon
> --
> 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

Re: [Jprogramming] Detecting special products

2015-08-06 Thread &#x27;Bo Jacoby&#x27; via Programming
   test=.[: +/ [: (= <.) [: > [: {: [: p. 1 0 _1 ,~ ]
- Bo
 


 Den 22:03 torsdag den 6. august 2015 skrev Roger Hui 
:
   
 

   g=: = (^&3 - ])@:(3&(>.@%:))
  g */"1 (10^40 60 80x)+/0 1 2
1 1 1


On Thu, Aug 6, 2015 at 11:23 AM, 'Pascal Jasmin' via Programming <
programm...@jsoftware.com> wrote:

> (] = (^&3 - ])@:(1r3 >.@^~ ])) 990
>
>
>
> - Original Message -
> From: Kip Murray 
> To: "programm...@jsoftware.com" 
> Cc:
> Sent: Thursday, August 6, 2015 1:58 PM
> Subject: [Jprogramming] Detecting special products
>
> The number  720  is  special: it is  8*9*10  the product of three
> successive non-negative integers.  The first few special numbers are
>
>    */"1 [ 0 1 2 +"1 0 i. 10
> 0 6 24 60 120 210 336 504 720 990
>
> Write a verb  test  that tests whether a non-negative integer is special:
>
>    test 720
> 1
>    test 0
> 1
>    test 721
> 0
>
> --Kip Murray
>
>
>
> --
> Sent from Gmail Mobile
> --
> 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


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

Re: [Jprogramming] Detecting special products

2015-08-08 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi Don.
The product of three consecutive numbers is y = (x-1)*x*(x+1) 
So x solves the equation  (1*x^3)+(0*x^2)+(_1*x^1)+(-y*x^0) = 0
If an   x  integer solves this equation, then the number  y  is special.

-- Bo
 


 Den 5:49 søndag den 9. august 2015 skrev Raul Miller 
:
   
 

 The product of three numbers in sequence can be represented as the
product of three simply polynomials:

  +//.@:(*/)/ 0 1,1 1,:2 1
0 2 3 1

That gets us another way of expressing our original expression:

  3 */\ i. 20
0 6 24 60 120 210 336 504 720 990 1320 1716 2184 2730 3360 4080 4896 5814
  0 2 3 1 p. i. 20
0 6 24 60 120 210 336 504 720 990 1320 1716 2184 2730 3360 4080 4896
5814 6840 7980

Now if we want to solve for x (the lowest of the three numbers in this
representation), we have:

  p = 0 + (2*x) + (3*x^2) + x^3
or
  0 = (-p)+(2*x) + (3*x^2) + x^3

And now we can look for the roots (and take advantage of a quirk of
their representation).

Good enough?

Thanks,

-- 
Raul


On Sat, Aug 8, 2015 at 11:39 PM, Don Guinn  wrote:
> Sorry I'm dense. I understand that. But the first polynomial is not
> remotely related to the second other than the gcd of both is x-8. Why?
> On Aug 8, 2015 8:08 PM, "'Pascal Jasmin' via Programming" <
> programm...@jsoftware.com> wrote:
>
>> (x-1)x(x+1) or x(x+1)(x+2) and their expansions are algebraic solutions to
>> special products.  All the solutions posted used one of these 2 forms.
>> (your example uses the 2nd's expansion)
>>
>>
>> - Original Message -
>> From: Don Guinn 
>> To: Programming forum 
>> Cc:
>> Sent: Saturday, August 8, 2015 9:53 PM
>> Subject: Re: [Jprogramming] Detecting special products
>>
>> Using polynomials to solve this problem is really neat, but why does it
>> work? I can't find anything on the internet explaining why it works.
>>
>>    p._720 2 3 1
>> +-++
>> |1|_5.5j7.72981 _5.5j_7.72981 8|
>> +-++
>>    p.1;-8 9 10
>> 720 242 27 1
>>
>> Obviously the polynomial for the roots is quite different from that used
>> above. There has to be a proof somewhere.
>>
>> On Fri, Aug 7, 2015 at 9:47 PM, Don Kelly  wrote:
>>
>> > correction : 'will be the  number of the sequence'
>> > in any case for a special number the real root will be an integer.
>> >
>> >
>> > On 06/08/2015 4:06 PM, Don Kelly wrote:
>> >
>> >> also try
>> >> 0=1|( <1; 2) {>p.|.1 3 2,-]720
>> >>
>> >> 1_
>> >>
>> >> 0=1|( <1; 2) {>p.|.1 3 2,-]719
>> >>
>> >> 0
>> >>
>> >>  note that
>> >> (<1;2) {>p._y 2 3 1
>> >> will return an integer for a special number and this will be the first
>> >> number of the sequence
>> >> based on x*x+1)*(x+2) -y=0 giving an integral root
>> >> p._720 2 3 1
>> >>
>> >> ┌─┬┐
>> >>
>> >> │1│_5.5j7.72981 _5.5j_7.72981 8│
>> >>
>> >> └─┴┘
>> >>
>> >>
>> >> a modification to x(x^2-1) gives an integral real root for the middle
>> root
>> >> p. _720 _1 0 1
>> >>
>> >> ┌─┬┐
>> >>
>> >> │1│9 _4.5j7.72981 _4.5j_7.72981│
>> >>
>> >> └─┴┘
>> >>
>> >> puts the real root first rather than last
>> >>
>> >> As for finding a list of these special numbers-the "stope " function
>> >> works well
>> >> f=:3^!.1~[:i.]
>> >>
>> >> f 10
>> >>
>> >> 0 6 24 60 120 210 336 504 720 990
>> >>
>> >>
>> >> Don Kelly
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On 06/08/2015 1:02 PM, Roger Hui wrote:
>> >>
>> >>>    g=: = (^&3 - ])@:(3&(>.@%:))
>> >>>    g */"1 (10^40 60 80x)+/0 1 2
>> >>> 1 1 1
>> >>>
>> >>>
>> >>> On Thu, Aug 6, 2015 at 11:23 AM, 'Pascal Jasmin' via Programming <
>> >>> programm...@jsoftware.com> wrote:
>> >>>
>> >>> (] = (^&3 - ])@:(1r3 >.@^~ ])) 990
>> 
>> 
>> 
>>  - Original Message -
>>  From: Kip Murray 
>>  To: "programm...@jsoftware.com" 
>>  Cc:
>>  Sent: Thursday, August 6, 2015 1:58 PM
>>  Subject: [Jprogramming] Detecting special products
>> 
>>  The number  720  is  special: it is  8*9*10  the product of three
>>  successive non-negative integers.  The first few special numbers are
>> 
>>       */"1 [ 0 1 2 +"1 0 i. 10
>>  0 6 24 60 120 210 336 504 720 990
>> 
>>  Write a verb  test  that tests whether a non-negative integer is
>>  special:
>> 
>>       test 720
>>  1
>>       test 0
>>  1
>>       test 721
>>  0
>> 
>>  --Kip Murray
>> 
>> 
>> 
>>  --
>>  Sent from Gmail Mobile
>>  --
>>  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
>> >>>
>> >>>
>> >> 

Re: [Jprogramming] Detecting special products

2015-08-09 Thread &#x27;Bo Jacoby&#x27; via Programming
NB. incorrect version using +/
   test=.[: +/ [: (= <.) [: > [: {: [: p. 1 0 _1 ,~ ]
   test"0] 3*/\i.20
3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
NB. corrected version version using +./
   test=.[: +./ [: (= <.) [: > [: {: [: p. 1 0 _1 ,~ ]
   test"0] 3*/\i.20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 


 Den 8:46 søndag den 9. august 2015 skrev 'Bo Jacoby' via Programming 
:
   
 

 Hi Don.
The product of three consecutive numbers is y = (x-1)*x*(x+1) 
So x solves the equation  (1*x^3)+(0*x^2)+(_1*x^1)+(-y*x^0) = 0
If an   x  integer solves this equation, then the number  y  is special.

-- Bo
 


    Den 5:49 søndag den 9. august 2015 skrev Raul Miller 
:
  
 

 The product of three numbers in sequence can be represented as the
product of three simply polynomials:

  +//.@:(*/)/ 0 1,1 1,:2 1
0 2 3 1

That gets us another way of expressing our original expression:

  3 */\ i. 20
0 6 24 60 120 210 336 504 720 990 1320 1716 2184 2730 3360 4080 4896 5814
  0 2 3 1 p. i. 20
0 6 24 60 120 210 336 504 720 990 1320 1716 2184 2730 3360 4080 4896
5814 6840 7980

Now if we want to solve for x (the lowest of the three numbers in this
representation), we have:

  p = 0 + (2*x) + (3*x^2) + x^3
or
  0 = (-p)+(2*x) + (3*x^2) + x^3

And now we can look for the roots (and take advantage of a quirk of
their representation).

Good enough?

Thanks,

-- 
Raul


On Sat, Aug 8, 2015 at 11:39 PM, Don Guinn  wrote:
> Sorry I'm dense. I understand that. But the first polynomial is not
> remotely related to the second other than the gcd of both is x-8. Why?
> On Aug 8, 2015 8:08 PM, "'Pascal Jasmin' via Programming" <
> programm...@jsoftware.com> wrote:
>
>> (x-1)x(x+1) or x(x+1)(x+2) and their expansions are algebraic solutions to
>> special products.  All the solutions posted used one of these 2 forms.
>> (your example uses the 2nd's expansion)
>>
>>
>> - Original Message -
>> From: Don Guinn 
>> To: Programming forum 
>> Cc:
>> Sent: Saturday, August 8, 2015 9:53 PM
>> Subject: Re: [Jprogramming] Detecting special products
>>
>> Using polynomials to solve this problem is really neat, but why does it
>> work? I can't find anything on the internet explaining why it works.
>>
>>    p._720 2 3 1
>> +-++
>> |1|_5.5j7.72981 _5.5j_7.72981 8|
>> +-++
>>    p.1;-8 9 10
>> 720 242 27 1
>>
>> Obviously the polynomial for the roots is quite different from that used
>> above. There has to be a proof somewhere.
>>
>> On Fri, Aug 7, 2015 at 9:47 PM, Don Kelly  wrote:
>>
>> > correction : 'will be the  number of the sequence'
>> > in any case for a special number the real root will be an integer.
>> >
>> >
>> > On 06/08/2015 4:06 PM, Don Kelly wrote:
>> >
>> >> also try
>> >> 0=1|( <1; 2) {>p.|.1 3 2,-]720
>> >>
>> >> 1_
>> >>
>> >> 0=1|( <1; 2) {>p.|.1 3 2,-]719
>> >>
>> >> 0
>> >>
>> >>  note that
>> >> (<1;2) {>p._y 2 3 1
>> >> will return an integer for a special number and this will be the first
>> >> number of the sequence
>> >> based on x*x+1)*(x+2) -y=0 giving an integral root
>> >> p._720 2 3 1
>> >>
>> >> ┌─┬┐
>> >>
>> >> │1│_5.5j7.72981 _5.5j_7.72981 8│
>> >>
>> >> └─┴┘
>> >>
>> >>
>> >> a modification to x(x^2-1) gives an integral real root for the middle
>> root
>> >> p. _720 _1 0 1
>> >>
>> >> ┌─┬┐
>> >>
>> >> │1│9 _4.5j7.72981 _4.5j_7.72981│
>> >>
>> >> └─┴┘
>> >>
>> >> puts the real root first rather than last
>> >>
>> >> As for finding a list of these special numbers-the "stope " function
>> >> works well
>> >> f=:3^!.1~[:i.]
>> >>
>> >> f 10
>> >>
>> >> 0 6 24 60 120 210 336 504 720 990
>> >>
>> >>
>> >> Don Kelly
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On 06/08/2015 1:02 PM, Roger Hui wrote:
>> >>
>> >>>    g=: = (^&3 - ])@:(3&(>.@%:))
>> >>>    g */"1 (10^40 60 80x)+/0 1 2
>> >>> 1 1 1
>> >>>
>> >>>
>> >>> On Thu, 

Re: [Jprogramming] Detecting special products

2015-08-10 Thread &#x27;Bo Jacoby&#x27; via Programming
The solutions based on (p.) are correct, but (p.) is insufficient. Roger's 
work-around is very nice! 

 


 Den 5:01 mandag den 10. august 2015 skrev Roger Hui 
:
   
 

 An advantage of solutions based on taking cube roots, on the expression
>.@%: in particular, is working correctly with large integers.  For example:

  g=: = (^&3 - ])@:(3&(>.@%:))

  n=: */ 0 1 2 + 11^20x
  n
304481639541418099575807073027324053193216441247734861355941206
  g n
1
  g n+1
0

In contrast:

  p. (-n),2 3 1
┌─┬┐
│1│6.7275e20 _3.36375e20j5.82619e20 _3.36375e20j_5.82619e20│
└─┴┘
  p. (-n+1),2 3 1
┌─┬┐
│1│6.7275e20 _3.36375e20j5.82619e20 _3.36375e20j_5.82619e20│
└─┴┘
  (p. (-n),2 3 1) -:!.0 p.(-n+1),2 3 1
1

The last expression shows that a solution based on p. can not discriminate
between n and n+1.
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] Detecting special products

2015-08-10 Thread &#x27;Bo Jacoby&#x27; via Programming
Note that (x-2)*(x-1)*x is equal to 6*3!x .
So the problem is reduced to identifying binomial coefficients.  


 Den 17:02 mandag den 10. august 2015 skrev 'Pascal Jasmin' via Programming 
:
   
 

 To answer why the last digit in p. result identifies whether it has integer 
root, no matter how many consecutive integers are used.

for 3 digits, the root will be x^3.  For 4, x^4, and the result of p. will 
identify x in that last location.


- Original Message -
From: Roger Hui 
To: Programming forum 
Cc: 
Sent: Monday, August 10, 2015 10:52 AM
Subject: Re: [Jprogramming] Detecting special products

p. orders the roots by decreasing magnitude, and within that (for roots
with equal magnitude) the ordering used by \: .  For example:

  p. p. < 3 1 4 1 5 9
┌─┬───┐
│1│9 5 4 3 1 1│
└─┴───┘
  p. p. <3 1 4 1 5 9 3j4 3j_4 _3j4 _3j_4
┌─┬───┐
│1│9 5 3j4 3j_4 _3j4 _3j_4 4 3 1 1│
└─┴───┘

If I may be permitted to show off a bit:

  p. p. <1+i.20x
┌─┬──┐
│1│20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1│
└─┴──┘

https://en.wikipedia.org/wiki/Wilkinson%27s_polynomial




On Mon, Aug 10, 2015 at 6:54 AM, Don Guinn  wrote:

> Thanks. I was being a little dense in forgetting that it is solving for x,
> not for all values. My thinking gets a little muddled with grandkids
> around. I was just surprised at the neatness of the solution.
>
> I played with products of consecutive numbers greater than 3 (are those
> still special products?) and p. still works until p. becomes unstable due
> to the order of the polynomial. I'm curious as to why the desired value for
> x is always the last root. Just the luck of the draw or is there some
> reason as to why it is always last. Do real values always come last? For
> the products of even consecutive numbers the number of real roots found by
> p. must be even. But the last one still seems to be the correct one.
>
> Take of two different product of 4 sequential numbers. Their gcd many cases
> is s special product. Those that aren't are a multiple of a special
> product. This seems to be the case that the gcd for the products of n
> consecutive integers is the a product or a multiple of n-1 and n-2 ...
> consecutive integers. The multiples seem to be in one consecutive group.
>
> Now that the grandkids are gone maybe I can play with this more with a
> clearer mind.
> --
> 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

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

Re: [Jprogramming] Resources for teachers & new users

2015-08-16 Thread &#x27;Bo Jacoby&#x27; via Programming
   load 'profiles/profiles/explorer'not found: 
c:/users/bo/j804/addons/profiles/profiles/explorer.ijs|file name error: script| 
0!:0 y[4!:55<'y'
What did I do wrong?
-- Bo
 


 Den 16:17 søndag den 16. august 2015 skrev R.E. Boss 
:
   
 

 > -Original Message-
> From: programming-boun...@forums.jsoftware.com [mailto:programming-
> boun...@forums.jsoftware.com] On Behalf Of Henry Rich
> Subject: [Jprogramming] Resources for teachers & new users
> 
> I have added some addons for new users.
> 
> 1. profiles/profiles has scripts to set up initial configurations for
> new users (well, actually, there's only one choice now, but you are
> welcome to add your own).

There is a typo in the caption.


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


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

Re: [Jprogramming] Resources for teachers & new users

2015-08-16 Thread &#x27;Bo Jacoby&#x27; via Programming
Thanks Henry Rich! But how  do I update the addons to get the profiles/profiles 
addon?
-- Bo.
 


 Den 4:41 mandag den 17. august 2015 skrev robert therriault 
:
   
 

 Thanks Bill,

I am running OSX 10.9.5 on an older machine (mid 2011 macbook pro), so I'll get 
back to you with what I find about getting the 64 bit version of j804 up and 
running. 

Cheers, bob

On Aug 16, 2015, at 6:41 PM, bill lam  wrote:

> @Bob: 
> This has been discussed within jqt team several times.  I think
> all osx later than 10.6.8 are 64-bits. Is this correct?  And
> j804 should be the last jqt version to support 10.6.8.
> 
> @Henry: 
> wd cmds in j804 should be backward compatible with j804,
> please develop and test your apps on j803 to avoid using new
> features introduced in j804, if you intended to support j803.
> 
> -- 
> regards,
> 
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> --
> 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

[Jprogramming] +. does not always work

2015-09-11 Thread &#x27;Bo Jacoby&#x27; via Programming
How do I make it less sensitive to round-off errors?Thank you.- Bo
   +./ 0.711*?100#1000.711
   +./ 0.711*?100#1001.28453e_13

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

Re: [Jprogramming] +. does not always work

2015-09-12 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you Raul!-- Bo 


 Den 4:21 lørdag den 12. september 2015 skrev Raul Miller 
:
   
 

 Does this help?

  +./ 0.711*t=:?100#100
1.01585e_13
  +./ x:0.711*t
711r1000

Thanks,

-- 
Raul


On Fri, Sep 11, 2015 at 9:14 PM, 'Bo Jacoby' via Programming
 wrote:
> How do I make it less sensitive to round-off errors?Thank you.- Bo
>    +./ 0.711*?100#1000.711
>    +./ 0.711*?100#1001.28453e_13
>
> --
> 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

Re: [Jprogramming] FW: December issue of Journal of J

2015-09-22 Thread &#x27;Bo Jacoby&#x27; via Programming
 Wikipedia:Reference desk/Mathematics - Wikipedia, the free encyclopedia
|   |
|   |  |   |   |   |   |   |
| Wikipedia:Reference desk/Mathematics - Wikipedia, the fr...The Wikipedia 
Reference Desk covering the topic of mathematics. Mathematics #eee #f5f5f5 #eee 
#aaa #aaa #aaa #00f #36b #000 #00f mathematics Wikipedia:Ref... |
|  |
| Se på en.wikipedia.org | Forhåndsvis efter Yahoo |
|  |
|   |


 


 Den 21:12 mandag den 21. september 2015 skrev Devon McCormick 
:
   
 

 I urge everyone to support this effort.  Having an online journal with a
history could prove valuable for promoting the language and having your
article published could help you!

On Mon, Sep 21, 2015 at 12:30 PM, mikel paternain 
wrote:

>
>
>
>
> Dear friends.
> We are preparing the December issue of JoJ.
>  , Send materials (letters, papers, etc.) before November 31.
> Thanks in advance.
> Mikel
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
--
For information about J forums see http://www.jsoftware.com/forums.htm


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

Re: [Jprogramming] Arrayfire bindings

2015-09-27 Thread &#x27;Bo Jacoby&#x27; via Programming
What is Arrayfire is all about?-- Bo
 


 Den 6:29 mandag den 28. september 2015 skrev 'Pascal Jasmin' via 
Programming :
   
 

 updated repo (bug fixes), and included a wiki page describing 
advantages/disadvantages of arrayfire.  https://github.com/Pascal-J/Jfire

On my low end GPU, I get a 250x speed improvement over J for floating point 
matrix multiplication on array size of 1024x1024 (including setup and results 
going back to J).




- Original Message -
From: Alex Shroyer 
To: programm...@jsoftware.com
Cc: 
Sent: Saturday, September 26, 2015 10:07 PM
Subject: Re: [Jprogramming] Arrayfire bindings

Very cool. I did an audio processing thing in J a while back which I think 
would have benefited from something like this. Perhaps now I'll re-implement it 
using Jfire.
Thanks for sharing!

Alex 

-Original Message-
From: "'Pascal Jasmin' via Programming" 
Sent: ‎9/‎26/‎2015 7:03 PM
To: "Programming Forum" 
Subject: [Jprogramming] Arrayfire bindings

https://github.com/Pascal-J/Jfire

There are probably some helpful applications for it.  Mostly with floating 
point. (A lot of work for something I don't use much :P)

Hope you like the interface for it.  Its fairly J like.
--
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

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

[Jprogramming] Koch island oneliner

2015-11-21 Thread &#x27;Bo Jacoby&#x27; via Programming
   'dot'plot +/\0,(13 :',y*/3%~_1^3%~0 5 1 0')^:6]_1^3%~2*i.3
J is amazing!.- Bo.
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Koch island oneliner

2015-11-21 Thread &#x27;Bo Jacoby&#x27; via Programming
Yes Linda, look at this:
http://www.cs.bu.edu/courses/Old/cs113/F97/roberts-source/PAC/05-Recursive-Procedures/koch.c

- Bo 


Den 22:19 lørdag den 21. november 2015 skrev Linda A Alvord 
:
 
 

 You too!  Is there some website which compares this to the Koch curve in other 
languanges?

Linda

-Original Message-
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of 'Bo Jacoby' via 
Programming
Sent: Saturday, November 21, 2015 3:16 AM
To: Programming Forum
Subject: [Jprogramming] Koch island oneliner

  'dot'plot +/\0,(13 :',y*/3%~_1^3%~0 5 1 0')^:6]_1^3%~2*i.3 J is amazing!.- Bo.
--
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

[Jprogramming] Work-around for FIFA/

2015-12-25 Thread &#x27;Bo Jacoby&#x27; via Programming
Dear experts.
This program works correctly for scalar input.
FIFA=.[([:+/!*2^-@>:@])(+i.&>:)
   2 FIFA 30.65625
It is the probability that the winning team of a soccermatch that ended 2-3, is 
indeed the better of the two teams.
I want a table, but (i.11)FIFA/ i.11 doesn't do it. What is the work-around?
Thanks. Bo.

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

Re: [Jprogramming] Work-around for FIFA/

2015-12-25 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you very much!- Bo
 

Den 15:07 fredag den 25. december 2015 skrev David Lambert 
:
 
 

     FIFA=.[([:+/!*2^-@>:@])(+i.&>:)

    FIFA b. 0  NB. FIFA has infinite rank
_ _ _


    + b. 0      NB. You need rank 0
0 0 0


    FIFA"0/~i.4x        NB. the table
  1r2  3r4  7r8 15r16
  1r4  1r2 11r16 13r16
  1r8 5r16  1r2 21r32
1r16 3r16 11r32  1r2



    NB. FIFA_NAUGHT requires rank 0
    NB. thus I'd make it part of the definition
    FIFA=. ([([:+/!*2^-@>:@])(+i.&>:))"0



    FIFA_NAUGHT/~i.4
    0.5  0.75  0.875  0.9375
  0.25    0.5  0.6875  0.8125
  0.125 0.3125    0.5 0.65625
0.0625 0.1875 0.34375    0.5



> Date: Fri, 25 Dec 2015 11:05:27 + (UTC)
> From: "'Bo Jacoby' via Programming"
> To: Programming Forum
> Subject: [Jprogramming] Work-around for FIFA/
> Message-ID:
>     <1537635543.5353562.1451041527345.javamail.ya...@mail.yahoo.com>
> Content-Type: text/plain; charset=UTF-8
>
> Dear experts.
> This program works correctly for scalar input.
> FIFA=.[([:+/!*2^-@>:@])(+i.&>:)
> ? ?2 FIFA 30.65625
> It is the probability that the winning team of a soccermatch that ended 2-3, 
> is indeed the better of the two teams.
> I want a table, but (i.11)FIFA/ i.11 doesn't do it. What is the work-around?
> Thanks. Bo.

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


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

Re: [Jprogramming] Bayesian links

2016-03-29 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you for the links!
One trouble about Bayesian statistics is the naming of probability. It is 
problematic to talk about the probability of life on Mars, because we do not 
have a big population of Marsplanets such that we can count the proportion of 
Marsplanets containing life.
Life on Mars is a hypothesis. Hypotheses do not have probabilities. Hypotheses 
have credibilities. It makes sense to talk about the credibility that there is 
life on Mars. 
This tiny change of wording may help accepting the Bayesian approach.
Secondly, the notation P(A|B) for the conditional probability of event A, given 
hypothesis B, can be simplified by omitting the letter P and writing simply 
(A|B). The unconditional probability of A is then written (A|0), and Bayes' 
rule reads
    (A|B)(B|0) = (A|0)(B|A)
meaning that the conditional probability times the prior credibility equals the 
unconditional probability times the posterior credibility.
Thirdly, consider these two J programs:
deduce=.%~`*`:3"2@(,: (%:@* -.))@(+/@[ %~ 1 , ,:)
 predict=.(deduce~ -@>:)~
They compute mean values and standard deviations.
If a population contains 20 items of category 1 and 5 items of category 2 and 0 
items of category 3, then a random sample of 10 items will contain 8±1  items 
of category 1 and 1±1 items of category 2 and 0±0  items of category 3. This 
was computed with program deduce like this:
   20 5 0 deduce 108 2 01 1 0
If a sample contains 20 items of category 1 and 5 items of category 2 and 0 
items of category 3, then another sample, of 10 items, will contain 7.5±1.6  
items of category 1 and 2.1±1.5 items of category 2 and 0.4±0.7  items of 
category 3. This was computed with program predict like this:
   20 5 0 predict 10 7.5 2.14286 0.3571431.56745 1.48533 0.671764
The close relationship between deduce and predict is the main result of this 
research: Statistical induction and prediction
Thanks. Bo.
 

Den 6:39 tirsdag den 29. marts 2016 skrev Ian Clark :
 
 

 You're welcome, Devon.

I've quite forgotten I'd done that. I recognise the article, now I see
it again. A bit of a Bayesian myself, I must have repaired it because
I remember thinking at the time what a good intro to Bayesianism it
was, with applications to human factors topics I was deeply into
throughout the 1980s. Yes, it needs J versions of the APL functions.

Amazed the APL chars have survived the migration to WikiMedia. Feel
free to strip out my initials etc and take back ownership of your
essay.

On Tue, Mar 29, 2016 at 1:14 AM, Devon McCormick  wrote:
> Hi - I've put up some links relating to my recent talk introducing Bayesian
> statistics - http://www.sigapl.org/BayesianLinks.php .
>
> Thanks to Ian Clark for reviving my old APL essay on this (
> http://code.jsoftware.com/wiki/User:Devon_McCormick/DynamicLinearModels/BayesianFinancialDynamicLinearModel_iac)
> by fixing the broken APL characters.  I may get around to re-doing this in
> J one of these days.
>
> --
>
> Devon McCormick, CFA
>
> Quantitative Consultant
> --
> 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

Re: [Jprogramming] Bayesian links

2016-03-29 Thread &#x27;Bo Jacoby&#x27; via Programming
I don''t know why the email became destroyed. Here I give extra carriage 
returns between then lines. The two program calls were:
   20 5 0 deduce 10

and
   20 5 0 predict 10
The output lines were
8 2 0
1 1 0
and
 7.5 2.14286 0.357143
1.56745 1.48533 0.671764
Thanks! 
Bo.

Den 16:23 tirsdag den 29. marts 2016 skrev Devon McCormick 
:
 
 

 Bo - your J examples came out garbled on my end, so I'm unsure what the
right-hand arguments are to both "deduce" and "predict".  Simply cutting
and pasting from your e-mail gives a result containing a complex number for
your first example and an error ("ill-formed number") for your second one.

On Tue, Mar 29, 2016 at 7:55 AM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

> Thank you for the links!
> One trouble about Bayesian statistics is the naming of probability. It is
> problematic to talk about the probability of life on Mars, because we do
> not have a big population of Marsplanets such that we can count the
> proportion of Marsplanets containing life.
> Life on Mars is a hypothesis. Hypotheses do not have probabilities.
> Hypotheses have credibilities. It makes sense to talk about the credibility
> that there is life on Mars.
> This tiny change of wording may help accepting the Bayesian approach.
> Secondly, the notation P(A|B) for the conditional probability of event A,
> given hypothesis B, can be simplified by omitting the letter P and writing
> simply (A|B). The unconditional probability of A is then written (A|0), and
> Bayes' rule reads
>    (A|B)(B|0) = (A|0)(B|A)
> meaning that the conditional probability times the prior credibility
> equals the unconditional probability times the posterior credibility.
> Thirdly, consider these two J programs:
> deduce=.%~`*`:3"2@(,: (%:@* -.))@(+/@[ %~ 1 , ,:)
>  predict=.(deduce~ -@>:)~
> They compute mean values and standard deviations.
> If a population contains 20 items of category 1 and 5 items of category 2
> and 0 items of category 3, then a random sample of 10 items will contain
> 8±1  items of category 1 and 1±1 items of category 2 and 0±0  items of
> category 3. This was computed with program deduce like this:
>    20 5 0 deduce 108 2 01 1 0
> If a sample contains 20 items of category 1 and 5 items of category 2 and
> 0 items of category 3, then another sample, of 10 items, will contain
> 7.5±1.6  items of category 1 and 2.1±1.5 items of category 2 and
> 0.4±0.7  items of category 3. This was computed with program predict like
> this:
>    20 5 0 predict 10 7.5 2.14286 0.3571431.56745 1.48533 0.671764
> The close relationship between deduce and predict is the main result of
> this research: Statistical induction and prediction
> Thanks. Bo.
>
>
>    Den 6:39 tirsdag den 29. marts 2016 skrev Ian Clark <
> earthspo...@gmail.com>:
>
>
>
>  You're welcome, Devon.
>
> I've quite forgotten I'd done that. I recognise the article, now I see
> it again. A bit of a Bayesian myself, I must have repaired it because
> I remember thinking at the time what a good intro to Bayesianism it
> was, with applications to human factors topics I was deeply into
> throughout the 1980s. Yes, it needs J versions of the APL functions.
>
> Amazed the APL chars have survived the migration to WikiMedia. Feel
> free to strip out my initials etc and take back ownership of your
> essay.
>
> On Tue, Mar 29, 2016 at 1:14 AM, Devon McCormick 
> wrote:
> > Hi - I've put up some links relating to my recent talk introducing
> Bayesian
> > statistics - http://www.sigapl.org/BayesianLinks.php .
> >
> > Thanks to Ian Clark for reviving my old APL essay on this (
> >
> http://code.jsoftware.com/wiki/User:Devon_McCormick/DynamicLinearModels/BayesianFinancialDynamicLinearModel_iac
> )
> > by fixing the broken APL characters.  I may get around to re-doing this
> in
> > J one of these days.
> >
> > --
> >
> > Devon McCormick, CFA
> >
> > Quantitative Consultant
> > --
> > 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
>



-- 

Devon McCormick, CFA

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

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

Re: [Jprogramming] divide if not zero

2016-05-06 Thread &#x27;Bo Jacoby&#x27; via Programming
x%y+y=0
 

Den 3:37 fredag den 6. maj 2016 skrev Joe Bogner :
 
 

 > > On 6 May 2016, at 10:53 AM, 'Pascal Jasmin' via Programming <
> programm...@jsoftware.com> wrote:
> >
> > I would go with first version.  What don't you like about it?

Thanks - I don't particularly like using explicit rank. It also fails on
the atom case

It's also not particularly fast:

6!:2 '(?1e6#5) %^:(0~:])"0 (?1e6#5)'

0.703749




On Thu, May 5, 2016 at 9:25 PM, Ric Sherlock  wrote:

> How about:
>
>    3 2 4 (% * 0 ~: ]) 6 0 3
>
> 0.5 0 1.3
>
>

Nice!

6!:2 '(?1e6#5) (% * 0 ~: ]) (?1e6#5)'

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

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

[Jprogramming] Help me using rank (")

2016-06-08 Thread &#x27;Bo Jacoby&#x27; via Programming
Dear J'ers. 
Please tell me how to program the 3 5 5 array below.
I am experimenting rather than understanding. I expect the answer to be quite 
elementary. 
Thanks! Bo.

0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4

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

Re: [Jprogramming] Help me using rank (")

2016-06-08 Thread &#x27;Bo Jacoby&#x27; via Programming
Thanks everyone!
This:
   0 2 1|:3 5 5$i.5

produces what I wanted.
The result is however destroyed in the process of emailing it to  
programm...@jsoftware.com . Line feeds are deleted. I don't  know why.
Problem is solved. Thanks again. 
Bo. 

Den 21:10 onsdag den 8. juni 2016 skrev Cliff Reiter 
:
 
 

 Or
,./": 3 5$"1 0 i.5

0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4

0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4

0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4

But a strange thing to want to build.

On 6/8/2016 1:37 PM, robert therriault wrote:
> Maybe this?
>
>      5( 3 #  ,:@,@":@:(#/"0)) i. 5
> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>
> But I am confused as well about the request for a shape 3 5 5 of what appears 
> as a shape 3 45 literal matrix. I do have '01' in mine though. :-)
>
> Cheers, bob
>  
>> On Jun 8, 2016, at 10:29 AM, Raul Miller  wrote:
>>
>> Did you mean something like this?
>>
>>    (<.0.8*1+i.25) 10&#./."1] 3#,:5# i.5
>> 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>> 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>> 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>>
>> Except, that doesn't get you those leading zeros for the '01' column,
>> so maybe instead it needs to be character?
>>
>> But a character array would not have anything to do with that 3 5 5
>> shape you suggested, so for that, and guessing what you want, maybe it
>> should be something like this?
>>
>>    <.25%~i.3 5 5
>> 0 0 0 0 0
>> 0 0 0 0 0
>> 0 0 0 0 0
>> 0 0 0 0 0
>> 0 0 0 0 0
>>
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>>
>> 2 2 2 2 2
>> 2 2 2 2 2
>> 2 2 2 2 2
>> 2 2 2 2 2
>> 2 2 2 2 2
>>
>> Except that that doesn't look at all like what you asked for. A 5 3 4
>> shape gets a little closer:
>>
>>    <.12%~i.5 3 4
>> 0 0 0 0
>> 0 0 0 0
>> 0 0 0 0
>>
>> 1 1 1 1
>> 1 1 1 1
>> 1 1 1 1
>>
>> 2 2 2 2
>> 2 2 2 2
>> 2 2 2 2
>>
>> 3 3 3 3
>> 3 3 3 3
>> 3 3 3 3
>>
>> 4 4 4 4
>> 4 4 4 4
>> 4 4 4 4
>>
>> But all of these have conflicts with some aspect of your original
>> request, and I can't figure out what it is that you really wanted.
>>
>> I hope this helps?
>>
>> Thanks,
>>
>> -- 
>> Raul
>>
>>
>> On Wed, Jun 8, 2016 at 5:22 AM, 'Bo Jacoby' via Programming
>>  wrote:
>>> Dear J'ers.
>>> Please tell me how to program the 3 5 5 array below.
>>> I am experimenting rather than understanding. I expect the answer to be 
>>> quite elementary.
>>> Thanks! Bo.
>>>
>>> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>>> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>>> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>>>
>>> --
>>> 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

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

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

Re: [Jprogramming] Help me using rank (")

2016-06-10 Thread &#x27;Bo Jacoby&#x27; via Programming
Thanks Raul!
To me (#:) was an intellectual detour, but it works beautifully.
Bo. 

Den 12:51 fredag den 10. juni 2016 skrev Raul Miller 
:
 
 

 Try this:
  3 5 5 #: i. 3 5 5

Then try this:
  1 {"1 (3 5 5 #: i. 3 5 5)

Then try this:
  #:"#:

I hope that helps,

Thanks,

-- 
Raul

On Fri, Jun 10, 2016 at 6:38 AM, Martin Kreuzer  wrote:
> Raul -
>
> Following this thread, I managed to grasp (reproduce) the expression (0 2 1
> |: 3 5 5 $ i. 5) which Bo found satisfactory.
>
> Challenged by your remark "But probably no easier to read." I have tried to
> sort of reconstruct your approach:
>
> First I read up on dyadic Antibase (x #: y) and found the remainder example;
> thus
>
>    > ,(i. 10) ;(5 #: i. 10)
> 0 1 2 3 4 5 6 7 8 9
> 0 1 2 3 4 0 1 2 3 4
>
> Producing this square matrix
>
>    i. 5 5
>  0  1  2  3  4
>  5  6  7  8  9
> 10 11 12 13 14
> 15 16 17 18 19
> 20 21 22 23 24
>
> and applying the above I got
>
>    5 #: i. 5 5
> 0 1 2 3 4
> 0 1 2 3 4
> 0 1 2 3 4
> 0 1 2 3 4
> 0 1 2 3 4
>
> and (5 #: i. 3 5 5) got me three blocks of those.
>
> Changing the axis preference (?) switched rows and columns
>
>    1 0 |: 5 #: i. 5 5
> 0 0 0 0 0
> 1 1 1 1 1
> 2 2 2 2 2
> 3 3 3 3 3
> 4 4 4 4 4
>
> and in the case of the three blocks this would be written as (0 2 1 |: 5 #:
> i. 3 5 5) as the number of blocks remains untouched.
>
> What seemed to me a shortcut for the special case of a three-dimensinal
> arrangement of square matrices this gives the same result:
>
>    1 |: 5 #: i. 3 5 5
> 0 0 0 0 0
> 1 1 1 1 1
> 2 2 2 2 2
> 3 3 3 3 3
> 4 4 4 4 4
>
> 0 0 0 0 0
> 1 1 1 1 1
> 2 2 2 2 2
> 3 3 3 3 3
> 4 4 4 4 4
>
> 0 0 0 0 0
> 1 1 1 1 1
> 2 2 2 2 2
> 3 3 3 3 3
> 4 4 4 4 4
>
> Using brackets I could write that as
>    (1 |: 5 #: i.) 3 5 5
> replacing the (5) by grabbing it from the list like (1 { 3 5 5)
> I continued to
>    (1 |: 1 & { #: i.) 3 5 5
> which looked promising.
>
> It looked to me as you were  taking advantage of the (1) being mentioned
> there twice and therefore combining, but ...
> Q: Could you enlighten me on this final step..?
>
> Thanks
> -M
>
>
>
>
> At 2016-06-10 06:51, you wrote:
>>
>> I just stumbled across this. It occurs to me that  (1&{@#:i.)3 5 5 would
>> be one character shorter. But probably no easier to read. Thanks, -- Raul On
>> Wed, Jun 8, 2016 at 5:31 PM, 'Bo Jacoby' via Programming
>>  wrote: > Thanks everyone! > This: >    0 2 1|:3
>> 5 5$i.5 > > produces what I wanted. > The result is however destroyed in the
>> process of emailing it to  programm...@jsoftware.com . Line feeds are
>> deleted. I don't  know why. > Problem is solved. Thanks again. > Bo. > >
>> Den 21:10 onsdag den 8. juni 2016 skrev Cliff Reiter
>> : > > > >  Or > ,./": 3 5$"1 0 i.5 > > 0 0 0 0 01 1 1
>> 1 12 2 2 2 23 3 3 3 34 4 4 4 4 > > 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4
>> 4 4 > > 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 > > But a strange
>> thing to want to build. > > On 6/8/2016 1:37 PM, robert therriault wrote: >>
>> Maybe this? >> >>      5( 3 #  ,:@,@":@:(#/"0)) i. 5 >> 0 0 0 0 01 1 1 1 12
>> 2 2 2 23 3 3 3 34 4 4 4 4 >> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4
>> >> 0 0 0 0 01 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 >> >> But I am confused as
>> well about the request for a shape 3 5 5 of what appears as a shape 3 45
>> literal matrix. I do have '01' in mine though. :-) >> >> Cheers, bob >> >>>
>> On Jun 8, 2016, at 10:29 AM, Raul Miller  wrote: >>>
>> >>> Did you mean something like this? >>> >>>    (<.0.8*1+i.25) 10&#./."1]
>> 3#,:5# i.5 >>> 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 >>> 0 0 0 0 1 1
>> 1 1 12 2 2 2 23 3 3 3 34 4 4 4 4 >>> 0 0 0 0 1 1 1 1 12 2 2 2 23 3 3 3 34 4
>> 4 4 4 >>> >>> Except, that doesn't get you those leading zeros for the '01'
>> column, >>> so maybe instead it needs to be character? >>> >>> But a
>> character array would not have anything to do with that 3 5 5 >>> shape you
>> suggested, so for that, and guessing what you want, maybe it >>> should be
>> something like this? >>> >>>    <.25%~i.3 5 5 >>> 0 0 0 0 0 >>> 0 0 0 0 0
>> >>> 0 0 0 0 0 >>> 0 0 0 0 0 >>> 0 0 0 0 0 >>> >>> 1 1 1

Re: [Jprogramming] Stats example ...

2016-06-13 Thread &#x27;Bo Jacoby&#x27; via Programming
   E+/ % # E 5 2 6 75 (-E) 5 2 6 70 _3 1 2 *:(-E) 5 2 6 70 9 1 4 E*:(-E) 5 2 6 
73.5 E&.:*:(-E) 5 2 6 71.87083
 

Den 18:33 mandag den 13. juni 2016 skrev Martin Kreuzer 
:
 
 

 Hi all -

While browsing the J NuVoc page I accidentally stumbled upon this example:

URL: http://code.jsoftware.com/wiki/Vocabulary/ampdotco

Under "Common Uses / 2. Compute standard deviation as the 
root-mean-square of a list of differences from the mean value"
the example starts out  with

y =: 0 _2 1 2          NB. list of differences from the mean value

This didn't look right to me as the sum of deviations does not result in zero:

    +/ 0 _2 1 2
1

So I made up an example myself:

    obs=. 5 2 6 7    NB. observed data
    amean=. +/ % #    NB. arithmetic mean
    dev=. ] - amean    NB. deviation from mean value
    dev obs
0 _3 1 2

Comparing this result with the above (original set of deviations)
makes me think it might be a typo.

The "mean deviation" (mean of absolute deviation values) would then be

    dmean=. amean @: |
    dmean dev obs
1.5

and the standard deviation (root-mean-square of deviation values)

    stddev=. amean &.: *:
    stddev dev obs
1.87083

Would somebody please have a look into that to check whether I'm 
utterly wrong or not..?

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

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

[Jprogramming] (1 _10)H.(_10)2 evaluates to infinity

2016-06-18 Thread &#x27;Bo Jacoby&#x27; via Programming
I was given this hint on how to compute a hypergeometric sum
Wikipedia:Reference desk/Mathematics - Wikipedia, the free encyclopedia

|   |
|   |  |   |   |   |   |   |
| Wikipedia:Reference desk/Mathematics - Wikipedia, the fr...The Wikipedia 
Reference Desk covering the topic of mathematics. Mathematics #eee #f5f5f5 #eee 
#aaa #aaa #aaa #00f #36b #000 #00f mathematics Wikipedia:Refe... |
|  |
| Se på en.wikipedia.org | Forhåndsvis efter Yahoo |
|  |
|   |


F =. 3 : '+/(2^i)*|:(!/~)|.i=.i.>:y'
 S =. 4 : '(y!x)*(1,-y)H.(-x)2'
 G =. 3 : '>y(S&.>)i.>:y'
 F 10 
1 12 67 232 562 1024 1486 1816 1981 2036 2047
    G 10

1 12 67 232 562 1024 1486 1816 1981 2036 _
 wa=. 4 : '((x=y)*<:2^>:x)+(-.x=y)*x S y' NB. work around
 H =. 3 : '>y(wa&.>)i.>:y'
 H 10
1 12 67 232 562 1024 1486 1816 1981 2036 2047
Question: Is it a bug that  (1 _10)H.(_10)2  evaluates to infinity?
Thanks! Bo.
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] (1 _10)H.(_10)2 evaluates to infinity

2016-07-02 Thread &#x27;Bo Jacoby&#x27; via Programming
The problem:
   (1 _10)H.(_10)2 
_
The solution:
   (1 _10)H.(_10+1e_7)2 
2047
Thanks!

Bo. 

Den 16:35 lørdag den 18. juni 2016 skrev 'Bo Jacoby' via Programming 
:
 
 

 I was given this hint on how to compute a hypergeometric sum
Wikipedia:Reference desk/Mathematics - Wikipedia, the free encyclopedia

|   |
|   |  |   |   |   |   |   |
| Wikipedia:Reference desk/Mathematics - Wikipedia, the fr...The Wikipedia 
Reference Desk covering the topic of mathematics. Mathematics #eee #f5f5f5 #eee 
#aaa #aaa #aaa #00f #36b #000 #00f mathematics Wikipedia:Refe... |
|  |
| Se på en.wikipedia.org | Forhåndsvis efter Yahoo |
|  |
|   |


F =. 3 : '+/(2^i)*|:(!/~)|.i=.i.>:y'
 S =. 4 : '(y!x)*(1,-y)H.(-x)2'
 G =. 3 : '>y(S&.>)i.>:y'
 F 10 
1 12 67 232 562 1024 1486 1816 1981 2036 2047
    G 10

1 12 67 232 562 1024 1486 1816 1981 2036 _
 wa=. 4 : '((x=y)*<:2^>:x)+(-.x=y)*x S y' NB. work around
 H =. 3 : '>y(wa&.>)i.>:y'
 H 10
1 12 67 232 562 1024 1486 1816 1981 2036 2047
Question: Is it a bug that  (1 _10)H.(_10)2  evaluates to infinity?
Thanks! Bo.
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] Centrobaric coordinates

2016-07-05 Thread &#x27;Bo Jacoby&#x27; via Programming
   $ (-56.298 -19.186 5.700)
2
 $ (_56.298 _19.186 5.700)
3
That's why!
Bo
 

Den 10:52 tirsdag den 5. juli 2016 skrev Papp Erik Tamás 
:
 
 

  
Dear Forum!
 
Can someone give me a little help to calculate centrobaric coordinates?
Still my solution works well, but something become wrong.

  NB. load a list of coordinates from file
  load'I:\FKJL.run'
  
  NB. list of coordinates file XYZ
  >FKJ
1    -91.406    53.344    8.320
2    -91.297    53.222    0.916
3    -60.158    24.280    8.948
4    -60.135    24.278    1.521
5    -56.298    -19.186    5.700
6    -13.269    -2.677    -1.444
7      -4.666    17.245    -1.605
8    -49.939    14.297    27.119
9    -52.769    11.523    25.906
10    -72.929    -8.630    27.146
11    -46.500    -30.291    23.078
12    -52.581    -22.934    5.676
13    -58.972    -17.511    18.862
14    -55.429    -26.155    23.077
15    -55.313    -26.131    23.039
16    -63.467    27.962    26.981
17    -57.673    22.069    25.782
18    -49.687    14.083    -3.666
  
  NB. compute centrobaric coordinates
  AS=:(".AKJ)-"1 RA=:(+/%#)".AKJ=:>,5}."1&.>,.FKJ  
  
  AKJ NB. list of coordinates without point number
 -91.406    53.344    8.320
 -91.297    53.222    0.916
 -60.158    24.280    8.948
 -60.135    24.278    1.521
 -56.298    -19.186    5.700
 -13.269    -2.677    -1.444
  -4.666    17.245    -1.605
 -49.939    14.297    27.119
 -52.769    11.523    25.906
 -72.929    -8.630    27.146
 -46.500    -30.291    23.078
 -52.581    -22.934    5.676
 -58.972    -17.511    18.862
 -55.429    -26.155    23.077
 -55.313    -26.131    23.039
 -63.467    27.962    26.981
 -57.673    22.069    25.782
 -49.687    14.083    -3.666
  
  RA NB. XYZ coordinates of center of gravity
_46.3969998 _29.3597779 _6.97183327
  
  AS NB. list of centrobaric coordinates = AKJ - RA
_45.0090007 _23.984 _1.34816676
_44.899 _23.862  6.05583323
_13.7610003  5.07977782 _1.97616677
            _13.738  5.08177806  5.45083328
 9.28499966  _21.238222  6.97183327
 34.3609997  29.3597779  6.97183327
 43.335  13.7197779  6.97183327
_3.54200016  15.0627779 _20.1471667
_6.3719  17.836778 _18.9341666
_17.9020008 _16.423  6.97183327
 30.187  5.9387  6.97183327
 16.746 _17.545  6.97183327
 4.9359  _10.750222  6.97183327
 17.1229998 _2.9946  6.97183327
 17.2149996 _2.91422216  6.97183327
            _17.07  1.3996 _20.0091669
_11.2760003  7.29077802 _18.8101667
0.375999767  18.9427778  6.97183327
  
  NB. wrong results, program running without error massage
  
  NB. check by hand calculation - lenght error
  (-91.406    53.344    8.320) - RA
_45.0090007 _23.984 _1.34816676
  (-91.297    53.222    0.916) - RA
_44.899 _23.862 6.05583323
  (-60.158    24.280    8.948) - RA
_13.7610003 5.07977782 _1.97616677
  (-60.135    24.278    1.521) - RA
_13.738 5.08177806 5.45083328
  (-56.298    -19.186    5.700) - RA
|length error
|  (-56.2980002-19.186 5.7002)    -RA
  
  
  $AKJ NB. string
18 29
  
  $RA
3
  
  $AS
18 3
  
  ".AKJ NB. do numbers from string ??? wrong
_91.4060006 _53.3440001  _8.3203
_91.2969997 _53.2220001 _0.91604
_60.1580001 _24.281  _8.9484
_60.1349998 _24.277  _1.5209
_37.1120002 _50.597                    0
            _12.036                  0                    0
_3.0614 _15.641                    0
            _49.939 _14.2970001              _27.119
_52.7689998            _11.523  _25.905
_64.2990007 _45.7830001                    0
            _16.209 _23.4220001                    0
_29.6470002 _46.9050001                    0
_41.460 _40.109                    0
_29.2740001 _32.3520004                    0
_29.1820002 _32.2740001                    0
_63.466            _27.962  _26.9810002
_57.6730002 _22.068              _25.782
_46.0210001            _10.417                    0
  
  As you can see when I try to convert a string to number, its not working.
 
Thank you in advance for your kind help.
 
Best regards,
 
Erik
 
papp.e...@ybl.szie.hu
 
--
For information about J forums see http://www.jsoftwa

[Jprogramming] Using the hypergeometric adverb (H.).

2016-07-07 Thread &#x27;Bo Jacoby&#x27; via Programming
I am estimating the number of known answers (x) in a multiple choice test, 
knowing the number of correctly  (y) and incorrectly  (n-y) answered questions. 
The computation shows that N=10 and y=8 gives x=5±2.
I would like to compress the three lines defining M0, M1 and M2 into at single 
line. 
Thank you!
Bo.
     M0=. 13 : '(1,-x)H.(-y+1e_7)2'

     M1=. 13 : '(2,-x)H.(-y+1e_7)2'
     M2=. 13 : '(3,-x)H.(-y+1e_7)2'
     M =. 13 : '>(i.>:y)(M0,M1,M2)&.>y'
     ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
     3":(i.@>:,ms) 10
 0 1 2 3 4 5 6 7 8 9 10
 0 0 0 1 1 2 3 4 5 7 9 
0 0 1 1 1 1 2 2 2 2 1
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Using the hypergeometric adverb (H.).

2016-07-07 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you very much, Raul. It works!
I agree that (+1e_7) makes the result slightly incorrect, but omitting it makes 
the result hugely incorrect. I suspect that it avoids a bug in (H.). 
   (1 _10 H. _10)2
_
 (1 _10 H. _10.01)2
2047
 Thanks.
Bo.

Den 23:47 torsdag den 7. juli 2016 skrev Raul Miller 
:
 
 

 Here is one approach:

Mn=: 13 :'y H.(-x+1e_7)2'"1
M=:  13 :'|:y Mn 1 2 3,&>/-i.1+y'
ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'

I'm not sure if that helps...

(I am also slightly dubious about that whole +1e_7 epsilon thing.)

-- 
Raul


On Thu, Jul 7, 2016 at 4:53 PM, 'Bo Jacoby' via Programming
 wrote:
> I am estimating the number of known answers (x) in a multiple choice test, 
> knowing the number of correctly  (y) and incorrectly  (n-y) answered 
> questions.
> The computation shows that N=10 and y=8 gives x=5±2.
> I would like to compress the three lines defining M0, M1 and M2 into at 
> single line.
> Thank you!
> Bo.
>      M0=. 13 : '(1,-x)H.(-y+1e_7)2'
>
>      M1=. 13 : '(2,-x)H.(-y+1e_7)2'
>      M2=. 13 : '(3,-x)H.(-y+1e_7)2'
>      M =. 13 : '>(i.>:y)(M0,M1,M2)&.>y'
>      ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
>      3":(i.@>:,ms) 10
>  0 1 2 3 4 5 6 7 8 9 10
>  0 0 0 1 1 2 3 4 5 7 9
> 0 0 1 1 1 1 2 2 2 2 1
> --
> 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

Re: [Jprogramming] Tacit Toolkit (was dyadic J)

2016-07-11 Thread &#x27;Bo Jacoby&#x27; via Programming
H2=.4 :'(x H.y)2'
 ms=.[:(([:<:{.),:[:%:{.*([:+:{:)-[:>:{.) 2%~/\(1 2 3,&>/[:-[)H2"1[:-1e_7+]
 6 6j2 6j2 ":|:7 8 9 10 ([,ms) 10
 7 3.73 1.96
 8 5.25 2.05
 9 7.05 1.87
 10 9.01 1.39
 

Den 21:58 søndag den 10. juli 2016 skrev Jose Mario Quintana 
:
 
 

 Exercise 8.  Rewrite the verb explicit verb ms shown below tacitly, as
usual, bonus points for a fixed tacit version (see the message [0]).

Mn=: 13 :'y H.(-x+1e_7)2'"1
M=:  13 :'|:y Mn 1 2 3,&>/-i.1+y'
ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
3":(i.@>:,ms) 10

A (wicked) solution follows after the warning.

[0]  [Jprogramming] Using the hypergeometric adverb (H.).
    http://www.jsoftware.com/pipermail/programming/2016-July/045466.html




  _|_|_|                      _|  _|
_|        _|_|_|      _|_|        _|    _|_|    _|  _|_|
  _|_|    _|    _|  _|    _|  _|  _|  _|_|_|_|  _|_|
      _|  _|    _|  _|    _|  _|  _|  _|        _|
_|_|_|    _|_|_|      _|_|    _|  _|    _|_|_|  _|    _|  _|  _|
          _|
          _|




The following is a slightly edited session:

  JVERSION
Engine: j805/j64/windows
Beta-9: commercial/2016-07-05T15:45:22
Library: 8.04.15
Qt IDE: 1.4.10/5.4.2
Platform: Win 64
Installer: J804 install
InstallPath: j:/program files/j
Contact: www.jsoftware.com

First, the explicit version,

  Mn=: 13 :'y H.(-x+1e_7)2'"1
  M=:  13 :'|:y Mn 1 2 3,&>/-i.1+y'
  ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
  3":(i.@>:,ms) 10
  0  1  2  3  4  5  6  7  8  9 10
  0  0  0  1  1  2  3  4  5  7  9
  0  0  1  1  1  1  2  2  2  2  1

Next, the tacit (fixed) version.

Running the J Wicket Toolkit (see the trailing message),

  (0!:0)<'/.../j wicked toolkit.ijs'

which is need it to define Mnt,

  Mnt=. (] train@:((an 2) ;~ Cloak <'H.')f. (-@:(1e_7 + [)))"1

  Mt=. |:@:(Mnt 1 2 3 ,&>/ -@:i.@:>:)

  mst=. (<:@:[ ,: %:@:([ * +:@:] - >:@:[))/@:|:@:(2 %~/\"1 Mt f.)





  3":(i.@>:,mst) 10

  0  1  2  3  4  5  6  7  8  9 10

  0  0  0  1  1  2  3  4  5  7  9

  0  0  1  1  1  1  2  2  2  2  1



  NB. It is fixed...

  66 (-@:[ ]\ 5!:5@<@:]) 'mst'

(<:@:[ ,: %:@:([ * +:@:] - >:@:[))/@:|:@:(2 %~/\"1 |:@:(((] ,^:(0:

``:)&6 :.(<@:((,'0') ,&< ]))@:((<(,'0');2) ;~ ,^:(0:`H.)) -@:(9.99

95e_8 + [))"1) (1 2 3 ,&>/ -@:i.@:>:)))



  (3":(i.@>:,ms) 100) -: (3":(i.@>:,mst) 100)

1


On Fri, Dec 18, 2015 at 7:33 PM, Jose Mario Quintana <
jose.mario.quint...@gmail.com> wrote:

> Dan wrote:
>
> At some point we’re going to have to put our heads together and create a
> JAL addon to collect all these utilities.
>
> "So much to do, so little time."  However, my current writing style might
> be perceived by many as nasty.  A sample follows together with an updated
> Wicked Tacit Toolkit (WTT) that must be pre-loaded.
>
> WARNING: The following is not for the faint-hearted :)
>
> http://www.collinsdictionary.com/dictionary/english/not-for-the-faint-hearted
>
> Fetch, From, Left and Right are among some added adverbs to the WTT which
> I find useful.  What do they do?
>
> From produces a related list of boxed verbs,
>
>    3  From
> ┌───┬───┬───┐
> │0&{│1&{│2&{│
> └───┴───┴───┘
>    _5 From
> ┌┬┬┬┬┐
> │_5&{│_4&{│_3&{│_2&{│_1&{│
> └┴┴┴┴┘
>
> Similiarly,
>
>    _3 Fetch
> ┌┬┬┐
> │_3&({::)│_2&({::)│_1&({::)│
> └┴┴┘
>    5 Fetch
> ┌───┬───┬───┬───┬───┐
> │0&({::)│1&({::)│2&({::)│3&({::)│4&({::)│
> └───┴───┴───┴───┴───┘
>
> Left and Right select arguments accordingly,
>
>    2  Fetch Right
> ┌──┬──┐
> │0&({::)@:]│1&({::)@:]│
> └──┴──┘
>    _3 From Left
> ┌───┬───┬───┐
> │_3&{@:[│_2&{@:[│_1&{@:[│
> └───┴───┴───┘
>
> When can they be useful?
>
> This is an illustration (rewriting sf1 adverb in the original thread),
>
>    'V0 V1 V2'  =. 3 Fetch Right
>    fg=. (0;1)&{:: NB. Fetching the gerund
>    sf1=. ((;:'@{}') train o ((V0 at [cv) ; V1 ; (V2 at ]cv))&:box fg) o
> tie&'' f.adv
>
>    _66 ]\ (5!:5)@< 'sf1'
> ("_)(((`'')(&(((;:'@{}') ,^:(0:``:)&6 :.(<@:((,'0') ,&< ]))@:((0&(
> {::)@:] ,^:(0:`@:) >@:((<[)"_)) ; 1&({::)@:] ; 2&({::)@:] ,^:(0:`@
> :) >@:((<])"_))&:(<@:(,^:(0:``:)&6 :.(<@:((,'0') ,&< ])))"0) (0;1)
> &({::))@:(,^:(0:``))&''@:(,^:(0:``:)&6 :.(<@:((,'0') ,&< ]))@:(<@:
> ((0;1;0)&({::@:[)))((`_)(`:6)))
>
>    NB. Testing...
>
>        (v0 v1 v2)sf1
> v0@:[ v1 v2@:]
> ┌─┬──┬─┐
> │┌──┬──┬─┐│v1│┌──┬──┬─┐│
> ││v0│@:│[││  ││v2│@:│]││
> │└──┴──┴─┘│  │└──┴──┴─┘│
> └─┴──┴─┘
>
>    3 4 (+: +  -:)sf1  2 4
> 7 10
>
> This is another version that might look a little less unfamiliar,
>
>    NB. Defining the darkhorse...
>
>    'ATOP LEFT RIGHT'=. 3 From Left
>    'V0  V1  V2'  =. 3 From Right
>
>    fg=. (0;1)&{:: NB. Fetching the gerund
>    workhorse=. (;:'@[]') (V0 , ATOP , LEFT , V1 , V2 , ATOP , RIGHT c) fg
>    darkhorse=. train o workhorse o tie&''
>
>    NB. Defining the adverb...
>
>    sf1=. darkhorse f.adv
>
>    

Re: [Jprogramming] Adverbial Tacit Jym

2016-07-11 Thread &#x27;Bo Jacoby&#x27; via Programming

Hi Jose! 
Thank you for your interest in my program.
I do not know if there exists a tacit version of  (13 :'x H. y 2')  . 
I do not share your allergy against 
[:-1e_7+] NB. 10 characters
as opposed to 
-@:(1e_7+]) NB. 12 characters

Normally I would prefer the shorter version.  
Bo. Den 1:32 tirsdag den 12. juli 2016 skrev Jose Mario Quintana 
:
 
 

 Your version would be a neat tacit rewriting of ms, except that you defined
H2 explicitly.  The hybrid nature of ms, written this way, is apparent when
one tries to fix it,

  ms f.
[: (([: <: {.) ,: [: %: {. * ([: +: {:) - [: >: {.) 2 %~/\ (1 2 3 ,&>/ [: -
[) 4 : '(x H.y)2'"1 [: - 9.9995e_8 + ]

Personally, I am allergic to forks with leading caps; but finding a remedy
a remedy is easy,

  ms=. (<:@:{. ,: %:@:({. * +:@:{: - >:@:{.))@:(2 %~/\ (1 2 3 ,&>/ -@:[)
H2"1 -@:(1e_7 + ]))

Either way, the tricky part is to rewrite H2 tacitly.




On Mon, Jul 11, 2016 at 3:46 AM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:
H2=.4 :'(x H.y)2'
 ms=.[:(([:<:{.),:[:%:{.*([:+:{:)-[:>:{.) 2%~/\(1 2 3,&>/[:-[)H2"1[:-1e_7+]
 6 6j2 6j2 ":|:7 8 9 10 ([,ms) 10
 7 3.73 1.96
 8 5.25 2.05
 9 7.05 1.87
 10 9.01 1.39


    Den 21:58 søndag den 10. juli 2016 skrev Jose Mario Quintana <
jose.mario.quint...@gmail.com>:



 Exercise 8.  Rewrite the verb explicit verb ms shown below tacitly, as
usual, bonus points for a fixed tacit version (see the message [0]).

Mn=: 13 :'y H.(-x+1e_7)2'"1
M=:  13 :'|:y Mn 1 2 3,&>/-i.1+y'
ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
3":(i.@>:,ms) 10

A (wicked) solution follows after the warning.

[0]  [Jprogramming] Using the hypergeometric adverb (H.).
    http://www.jsoftware.com/pipermail/programming/2016-July/045466.html




  _|_|_|                      _|  _|
_|        _|_|_|      _|_|        _|    _|_|    _|  _|_|
  _|_|    _|    _|  _|    _|  _|  _|  _|_|_|_|  _|_|
      _|  _|    _|  _|    _|  _|  _|  _|        _|
_|_|_|    _|_|_|      _|_|    _|  _|    _|_|_|  _|    _|  _|  _|
          _|
          _|




The following is a slightly edited session:

  JVERSION
Engine: j805/j64/windows
Beta-9: commercial/2016-07-05T15:45:22
Library: 8.04.15
Qt IDE: 1.4.10/5.4.2
Platform: Win 64
Installer: J804 install
InstallPath: j:/program files/j
Contact: www.jsoftware.com

First, the explicit version,

  Mn=: 13 :'y H.(-x+1e_7)2'"1
  M=:  13 :'|:y Mn 1 2 3,&>/-i.1+y'
  ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
  3":(i.@>:,ms) 10
  0  1  2  3  4  5  6  7  8  9 10
  0  0  0  1  1  2  3  4  5  7  9
  0  0  1  1  1  1  2  2  2  2  1

Next, the tacit (fixed) version.

Running the J Wicket Toolkit (see the trailing message),

  (0!:0)<'/.../j wicked toolkit.ijs'

which is need it to define Mnt,

  Mnt=. (] train@:((an 2) ;~ Cloak <'H.')f. (-@:(1e_7 + [)))"1

  Mt=. |:@:(Mnt 1 2 3 ,&>/ -@:i.@:>:)

  mst=. (<:@:[ ,: %:@:([ * +:@:] - >:@:[))/@:|:@:(2 %~/\"1 Mt f.)





  3":(i.@>:,mst) 10

  0  1  2  3  4  5  6  7  8  9 10

  0  0  0  1  1  2  3  4  5  7  9

  0  0  1  1  1  1  2  2  2  2  1



  NB. It is fixed...

  66 (-@:[ ]\ 5!:5@<@:]) 'mst'

(<:@:[ ,: %:@:([ * +:@:] - >:@:[))/@:|:@:(2 %~/\"1 |:@:(((] ,^:(0:

``:)&6 :.(<@:((,'0') ,&< ]))@:((<(,'0');2) ;~ ,^:(0:`H.)) -@:(9.99

95e_8 + [))"1) (1 2 3 ,&>/ -@:i.@:>:)))



  (3":(i.@>:,ms) 100) -: (3":(i.@>:,mst) 100)

1


On Fri, Dec 18, 2015 at 7:33 PM, Jose Mario Quintana <
jose.mario.quint...@gmail.com> wrote:

> Dan wrote:
>
> At some point we’re going to have to put our heads together and create a
> JAL addon to collect all these utilities.
>
> "So much to do, so little time."  However, my current writing style might
> be perceived by many as nasty.  A sample follows together with an updated
> Wicked Tacit Toolkit (WTT) that must be pre-loaded.
>
> WARNING: The following is not for the faint-hearted :)
>
>
http://www.collinsdictionary.com/dictionary/english/not-for-the-faint-hearted
>
> Fetch, From, Left and Right are among some added adverbs to the WTT which
> I find useful.  What do they do?
>
> From produces a related list of boxed verbs,
>
>    3  From
> +---+
> ¦0&{¦1&{¦2&{¦
> +---+
>    _5 From
> ++
> ¦_5&{¦_4&{¦_3&{¦_2&{¦_1&{¦
> ++
>
> Similiarly,
>
>    _3 Fetch
> +--+
> ¦_3&({::)¦_2&({::)¦_1&({::)¦
> +--+
>    5 Fetch
> +---

Re: [Jprogramming] Adverbial Tacit Jym

2016-07-13 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi Jose!
I cannot comment on your tacit version of 13 : 'x H. y 2' because I do not 
understand it, but it is nice that it exists.
Nor do I understand your request to generalize from vector to matrix. 
The problem solved was this. A student performing a multiple choice test knew  
x  answers and guessed the remaining  n-x  answers correctly with probability 
50% and incorrectly with probability 50%. So he provided  y  correct and  n-y  
incorrect answers. The task is to estimate the unknown number  x  from the 
known numbers  n  and  y .
I got help here:  
https://en.wikipedia.org/wiki/User_talk:Joel_B._Lewis#Analyzing_the_multiple_choice_test
 
The troublesome sums were expressed in terms of hypergeometric functions. Raul 
Miller helped me with the J code. 
   H2=.4 :'x H.y 2'
   ms=.[:(([:<:{.),:[:%:{.*([:+:{:)-[:>:{.)2%~/\(1 2 3,&>/[:-[)H2"1[:-1e_7+]
   5j1":|:(10+i.11) ([,ms) 20
 10.0 2.7 2.1
 11.0 3.5 2.5
 12.0 4.6 2.8
 13.0 5.9 3.0
 14.0 7.4 3.2
 15.0 9.2 3.2
 16.0 11.0 3.1
 17.0 13.0 2.8
 18.0 15.0 2.4
 19.0 17.0 2.0
 20.0 19.0 1.4
 How do you want to extend this to matrices?
Thanks. Bo.

Den 19:20 onsdag den 13. juli 2016 skrev Jose Mario Quintana 
:
 
 

 Hi Bo,

In principle, any explicit verb can be rewritten tacitly.  In practice,
sometimes this can be very difficult if one adheres to the Dictionary
rules; however, with some familiarity it is usually easy as long as one is
willing to bend the rules (and expressions such as  13 :'x H. y 2'  can
even be translated automatically with the right tool).  I provided an
embedded hand-coded tacit form of H2 in my reply (search below for the
entry 'Mnt=.'  and compare it to the entry 'Mn=.') using a wicked tacit
toolkit.  An alternative stand-alone tacit version of H2 follows, (mind
you, it is long vs its explicit counterpart),

h2=. ,^:(0:`(<'`:'))&6@:([,(<'H.'),(<2;~":0),~])&:(<@:((":0) ; ]))

While I have your attention, I hope, I would like to ask you a question
regarding your simplify verb [0]:  Do you have a similar verb when instead
of having a univariate sample (vector) one has a multivariate sample
(matrix)?  I would be interested to see a version even if it is restricted
to matching just the first two moments (the mean and variance-covariance of
the sample).


[0]  [Jprogramming] simplify
      http://www.jsoftware.com/pipermail/programming/2015-June/042130.html

On Tue, Jul 12, 2016 at 1:09 AM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

>
> Hi Jose!
> Thank you for your interest in my program.
> I do not know if there exists a tacit version of  (13 :'x H. y 2')  .
> I do not share your allergy against
> [:-1e_7+] NB. 10 characters
> as opposed to
> -@:(1e_7+]) NB. 12 characters
>
> Normally I would prefer the shorter version.
> Bo.    Den 1:32 tirsdag den 12. juli 2016 skrev Jose Mario Quintana <
> jose.mario.quint...@gmail.com>:
>
>
>
>  Your version would be a neat tacit rewriting of ms, except that you
> defined
> H2 explicitly.  The hybrid nature of ms, written this way, is apparent when
> one tries to fix it,
>
>  ms f.
> [: (([: <: {.) ,: [: %: {. * ([: +: {:) - [: >: {.) 2 %~/\ (1 2 3 ,&>/ [: -
> [) 4 : '(x H.y)2'"1 [: - 9.9995e_8 + ]
>
> Personally, I am allergic to forks with leading caps; but finding a remedy
> a remedy is easy,
>
>  ms=. (<:@:{. ,: %:@:({. * +:@:{: - >:@:{.))@:(2 %~/\ (1 2 3 ,&>/ -@:[)
> H2"1 -@:(1e_7 + ]))
>
> Either way, the tricky part is to rewrite H2 tacitly.
>
>
>
>
> On Mon, Jul 11, 2016 at 3:46 AM, 'Bo Jacoby' via Programming <
> programm...@jsoftware.com> wrote:
> H2=.4 :'(x H.y)2'
>  ms=.[:(([:<:{.),:[:%:{.*([:+:{:)-[:>:{.) 2%~/\(1 2 3,&>/[:-[)H2"1[:-1e_7+]
>  6 6j2 6j2 ":|:7 8 9 10 ([,ms) 10
>  7 3.73 1.96
>  8 5.25 2.05
>  9 7.05 1.87
>  10 9.01 1.39
>
>
>    Den 21:58 søndag den 10. juli 2016 skrev Jose Mario Quintana <
> jose.mario.quint...@gmail.com>:
>
>
>
>  Exercise 8.  Rewrite the verb explicit verb ms shown below tacitly, as
> usual, bonus points for a fixed tacit version (see the message [0]).
>
> Mn=: 13 :'y H.(-x+1e_7)2'"1
> M=:  13 :'|:y Mn 1 2 3,&>/-i.1+y'
> ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
> 3":(i.@>:,ms) 10
>
> A (wicked) solution follows after the warning.
>
> [0]  [Jprogramming] Using the hypergeometric adverb (H.).
>    http://www.jsoftware.com/pipermail/programming/2016-July/045466.html
>
>
>
>
>  _|_|_|                      _|  _|
> _|        _|_|_|      _|_|        _|    _|_|    _|  _|_

Re: [Jprogramming] simplify

2016-07-17 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi Jose.
No sir! I have not considered that generalization of the verb 'simplify'. I 
will look into it. 
(I must remember to use double enter in order that the mail program does not 
mess up my mail.)
(k simplify n)  has the same k moments as vector  n.
Examples of simplify:
   simplify
4 : 0
y=.x*}.(%{.)+/y^/i.>:x
x=.1
for.y do.x=.((-/x*(#x){.y)%#x),x end.
-|.>{:p.x
) 
   ]n=.?8#0 NB. test data
0.17212 0.51129 0.190085 0.752359 0.223673 0.177596 0.730671 0.766152

 1 simplify n NB. mean value
0.440493 

 2 simplify n NB. mean plusminus std.dev.
0.179873 0.701114

 3 simplify n
0.138829 0.407932 0.774719

 (3 & simplify &. (10&+)) n NB. adding a constant 
0.138829 0.407932 0.774719


 (3 & simplify &. (10&*)) n NB. multiply by constant
0.138829 0.407932 0.774719


 2 simplify 3 simplify n NB. further simplifying
0.179873 0.701114

1 simplify 2 simplify n NB. further simplifying
0.440493

Thanks! Bo.
 

Den 21:16 søndag den 17. juli 2016 skrev Jose Mario Quintana 
:
 
 

 Hi Bo,

The particular monadic case 2&simplify, as I understand it, produces a
vector (of size two) which has the same two moments as the original vector
(e.g., if the argument  Y  is a vector of univariate observations, for
instance the heights of a group of  N  people then the product of
 2&simplify Y  would be a vector Z  of two "heights" which would have the
same mean and variance as  Y ).

Now, assume one also has the weights of the same group of people and the
bivariate observations  Y  contains now their heights and weights collected
as a matrix with  N  rows and two columns (height and weight).  The problem
is: find another matrix  Z  of "heights and weights" with a minimum number
 M  of rows (M <: N) such that the (1x2) mean vector and the (2x2)
variance-covariance matrix  of Z are the same as the mean and
variance-covariance matrix of  Y .  More generally, what would be the
corresponding Z for multivariate observations?  (I guess the number of rows
 M  , apart from rounding, should depend linearly on the number of columns
of the multivariate observations.)

I was just wondering if you had consider that kind of problems.



On Fri, Jun 26, 2015 at 3:50 AM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

> Explanation: The vector 'A simplify B' has the same A moments as the
> vector B.Examples:  1 simplify 0 21  2 simplify 0 20 2  3 simplify 0
> 2_0.224745 1 2.22474  2 simplify 3 simplify 0 20 2  1 simplify 3 simplify
> 0 21
>
>
>
>
>      Den 0:04 fredag den 26. juni 2015 skrev Kip Murray <
> thekipmur...@gmail.com>:
>
>
>
>  1 X
>
>  2 X X
>
>  3
>
>  4 X
>
>  5
>
>  6 X
>
>
>  1 X
>
>  2
>
>  3 X
>
>  4
>
>  5 X
>
>  6
>
>
>  1
>    X
>  2 X
>
>  3
>
>  4
>
>  5 X
>
>  6
>
>
> Above I have attempted three histograms.  The first shows the data set 1 2
> 2 4 6 which has mean 3 and standard deviation 2, median 2 and fourths (not
> quartiles) 1.5 and 5 .  The second histogram shows the mean and the mean
> plus or minus a standard deviation, and the third histogram shows the
> median and fourths.  (The fourths are respectively the median of the
> numbers below the median, and the median of the numbers above the median.)
>
> --Kip Murray
>
>
> On Thursday, June 25, 2015, Devon McCormick  wrote:
>
> > I put together this J based on the "fivenum" routine in R mentioned in
> the
> > Wikipedia link:
> >
> > fivenum=: 3 : 0
> >    if. 0=#y=. /:~y do. 5#_.
> >    else. n4=. -:<.-:3+#y
> >        d=. <:1,n4,(-:>:#y),(n4-~>:#y),#y
> >        -:(y{~<.d)+y{~>.d
> >    end.
> > )
> >
> > It returns the minimum, the quartile points, and the maximum of a series.
> > The first branch of the "if" roughly replicates some of the R function's
> > NA-handling.
> >
> > On Thu, Jun 25, 2015 at 10:14 AM, David Lambert  > >
> > wrote:
> >
> > > Is simplify supposed to report the i.x moments of the data?  Would be
> > > useful.
> > > When I removed the question marks from simplify to make valid j
> > >    1 simplify DATA NB. does report the mean
> > > Otherwise I haven't made sense of the results for the verb I created.
> > >
> > >    datatype N
> > > integer
> > >
> > >    3 simplify N
> > > _951.236j1533.8 _951.236j_1533.8 2658.39
> > >
> > >  Date: Thu, 25 Jun 2015 08:39:51 + (UTC)
> > >> From: "'Bo Jacoby' via Programming" > >
> > >> To: Programming Forum>
> > >> Subject: [Jprogramming] s

Re: [Jprogramming] Wiki: Energy Usage Analysis

2016-08-25 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi!
When you have got positive numbers only, then first take the logarithm, because 
whatever calculation you make you never want negative values. Next multiply by 
100 because the accuracy of the measurements is around 1 percent. Next round to 
integer values because the fractional part is uninteresting.
([:<.[:100&*^.)

Then make a discrete fourier transform to get a power spectrum. Low frequency 
peaks tell the base load. High frequency peaks tell how often the air 
conditioner turns on. 
Good luck!
Bo. 

 

Den 7:20 fredag den 26. august 2016 skrev dhkelly :
 
 

 I would suggest that you could get away with samples taken at longer 
intervals. You won't lose useful information as none of the major 
appliances including the air conditioner should draw a startup peak 
power for over  6 seconds and what you really need is the increase in 
load over a longer time. In addition, the air conditioner is a motor 
load which has a lower power factor than something dominated by a heater 
element.

A change  between two readings  at the interval you are using or an 
interval of the order of 60 seconds (or longer)  will essentially give 
the same information -something changed in the interval- whatever it 
is.  Determining whatever is a bit more iffy. If you get large jumps at 
2AM- blame the air conditioner. If at 8AM it could be stove and/or water 
heater (breakfast and shower) indicating that you got up then.
The trouble with a whole house monitor, is that a measure of changes in 
power alone, may not really give you all the data to distinguish 
sources. Another is that a high sampling rate may give variations that 
are really not of interest.  I think that a step would be to correlate 
the data with your direct observations of what went on or off - when( 
i.e at the time you turned on a major load such as a stove or dryer- 
both of which will cycle their power levels "on/off"  in the same way 
that an air-conditioner does.
(e.g. an oven will turn on until the desired temperature is reached, 
then turn off , repeating this cycle to maintain a a given temperature 
(+/- a bit) just as an air conditioner or dryer does).

Don Kelly



Does the meter also measure power factor or "vars"?



On 8/25/2016 8:05 PM, Joe Bogner wrote:
> I posted an article that looks at some data I captured using a whole-home
> energy monitor. I also posted the data.  I put up a challenge for anyone
> who wants to take a stab at it.
>
> http://code.jsoftware.com/wiki/User:Joe_Bogner/EnergyUsageAnalysis
>
> How often does the air conditioner or clothes dryer turn on?
> How long does it normally run, when did it run the longest?
> Is it possible to determine when I go to bed or wake up?
>
> I'd be interested in any approaches to answering any of these questions or
> other analysis on the data
>
> For example, the air conditioner draws a significant amount of energy.  I
> just turned it on and my usage went from 1460-6000 watts.
>
> Looking at the change in prior reading may be a good start
>
> plot (}. reading - (_1 |.!.0 reading))
>
> I have an electric dryer and electric oven.
>
> I hope the data and article is interesting/useful
> --
> 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

Re: [Jprogramming] Counting characters

2016-09-13 Thread &#x27;Bo Jacoby&#x27; via Programming
ts1 =. [:+/"1'abc'=/]
 

Den 5:18 onsdag den 14. september 2016 skrev Henry Rich 
:
 
 

 ts3 =: +/@:=~"0 _

'abc' ts3 'abcbdefbbcbaa'

3 5 2


Henry Rich

On 9/13/2016 11:13 PM, 'Pascal Jasmin' via Programming wrote:
> 'abc' ts2 'abcbdefbbcbaa'

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

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

[Jprogramming] 13 : '-:y+0 1 2=?3'

2016-11-02 Thread &#x27;Bo Jacoby&#x27; via Programming

The following J-code produces the Sierpinski triangle.
f=. 3 : '-:y+0 1 2=?3'
'dot'plot+/(3%:_1 0 1)*|:f^:(i.1)1 1 1%3

Note however that the tacit code generator (13 :) evaluates the random number 
generator (?) at compile time rather than at run time.
   13 : '-:y+0 1 2=?3'
[: -: 1 0 0 + ]
I think that is a bug.
Thank you.
Bo.
Game of Chaos

  
|  
|   |  
Game of Chaos
 Java applet that produces the Sierpinski triangle by shooting dice  |  |

  |

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

Re: [Jprogramming] J805 - install it!

2016-12-20 Thread &#x27;Bo Jacoby&#x27; via Programming
After installing J805 :
load'plot'
not found: c:/program files/j805/addons/graphics/plot/plot.ijs|file name error: 
script| 0!:0 y[4!:55<'y'
?
Bo.

 

Den 2:45 tirsdag den 20. december 2016 skrev bill lam :
 
 

 I also heard beta test can deploy app without uploading to app store.

https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html

On 20 Dec, 2016 9:35 am, "Raul Miller"  wrote:

> Maybe you need to be charging a fee for copies sold through the Apple
> store, to cover those issues?
>
> --
> Raul
>
>
> On Mon, Dec 19, 2016 at 8:17 PM, bill lam  wrote:
> > hypothetical jqt can run on iOS but the main difficulty is still Apple
> > store policy.
> >
> >
> > On 20 Dec, 2016 1:30 am, "Kip Murray"  wrote:
> >
> >> I have installed J805 on my ancient Windows 32 computer and am able to
> use
> >> Jqt.
> >>
> >> My primary use of J is on my iPad Air.  Is there any news on that front?
> >>
> >> --Kip Murray
> >>
> >> On Monday, December 19, 2016, Eric Iverson 
> >> wrote:
> >>
> >> > Installing J805 is strongly recommended for all users.
> >> >
> >> > For some previous releases there were various reasons why some users
> >> would
> >> > hold of on moving to a new release. This is not the case for this
> >> release.
> >> >
> >> > Everyone should move to 805 ASAP. It is in your interest and the
> >> > communities interest.
> >> >
> >> > Install instructions have been significantly reworked. Taking time to
> >> > follow them carefully and providing feedback will help clean things
> up so
> >> > new users will have a smoother ride.
> >> >
> >> > See www.jsoftware.com and click Download.
> >> > 
> --
> >> > For information about J forums see http://www.jsoftware.com/
> forums.htm
> >>
> >>
> >>
> >> --
> >> Sent from Gmail Mobile
> >> --
> >> 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
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] J805 - install it!

2016-12-20 Thread &#x27;Bo Jacoby&#x27; via Programming
I don't know if I did install addons. I entered System/Installation/All-in-One 
- J Wikiand executed program j805_win32.exe. Shall it be redone?Thanks!Bo.
  
|  
|   
|   
|   ||

   |

  |
|  
|   |  
System/Installation/All-in-One - J Wiki
   |   |

  |

  |

 
 

Den 10:05 tirsdag den 20. december 2016 skrev bill lam 
:
 
 

 For the jqt route, one doesn't need j/iphone source code.
Download the jqt source and play with it.

Пн, 19 дек 2016, Xiao-Yong Jin написал(а):
> If you guys release the source code, anyone with a free apple ID account can 
> build and run without going through the app store.
> 
> https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYourApponDevices.html
> 
> 
> > On Dec 19, 2016, at 8:45 PM, bill lam  wrote:
> > 
> > I also heard beta test can deploy app without uploading to app store.
> > 
> > https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html
> > 
> > On 20 Dec, 2016 9:35 am, "Raul Miller"  wrote:
> > 
> >> Maybe you need to be charging a fee for copies sold through the Apple
> >> store, to cover those issues?
> >> 
> >> --
> >> Raul
> >> 
> >> 
> >> On Mon, Dec 19, 2016 at 8:17 PM, bill lam  wrote:
> >>> hypothetical jqt can run on iOS but the main difficulty is still Apple
> >>> store policy.
> >>> 
> >>> 
> >>> On 20 Dec, 2016 1:30 am, "Kip Murray"  wrote:
> >>> 
>  I have installed J805 on my ancient Windows 32 computer and am able to
> >> use
>  Jqt.
>  
>  My primary use of J is on my iPad Air.  Is there any news on that front?
>  
>  --Kip Murray
>  
>  On Monday, December 19, 2016, Eric Iverson 
>  wrote:
>  
> > Installing J805 is strongly recommended for all users.
> > 
> > For some previous releases there were various reasons why some users
>  would
> > hold of on moving to a new release. This is not the case for this
>  release.
> > 
> > Everyone should move to 805 ASAP. It is in your interest and the
> > communities interest.
> > 
> > Install instructions have been significantly reworked. Taking time to
> > follow them carefully and providing feedback will help clean things
> >> up so
> > new users will have a smoother ride.
> > 
> > See www.jsoftware.com and click Download.
> > 
> >> --
> > For information about J forums see http://www.jsoftware.com/
> >> forums.htm
>  
>  
>  
>  --
>  Sent from Gmail Mobile
>  --
>  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
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
> 
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] J805 - install it!

2016-12-20 Thread &#x27;Bo Jacoby&#x27; via Programming
I get the message: "Unable to run Package Manager, as you do not have access to 
the installation folder." 

Den 12:31 tirsdag den 20. december 2016 skrev 'Bo Jacoby' via Programming 
:
 
 

 I don't know if I did install addons. I entered System/Installation/All-in-One 
- J Wikiand executed program j805_win32.exe. Shall it be redone?Thanks!Bo.
  
|  
|  
|  
|  |    |

  |

  |
|  
|  |  
System/Installation/All-in-One - J Wiki
  |  |

  |

  |

 
 

    Den 10:05 tirsdag den 20. december 2016 skrev bill lam 
:
 
 

 For the jqt route, one doesn't need j/iphone source code.
Download the jqt source and play with it.

Пн, 19 дек 2016, Xiao-Yong Jin написал(а):
> If you guys release the source code, anyone with a free apple ID account can 
> build and run without going through the app store.
> 
> https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYourApponDevices.html
> 
> 
> > On Dec 19, 2016, at 8:45 PM, bill lam  wrote:
> > 
> > I also heard beta test can deploy app without uploading to app store.
> > 
> > https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html
> > 
> > On 20 Dec, 2016 9:35 am, "Raul Miller"  wrote:
> > 
> >> Maybe you need to be charging a fee for copies sold through the Apple
> >> store, to cover those issues?
> >> 
> >> --
> >> Raul
> >> 
> >> 
> >> On Mon, Dec 19, 2016 at 8:17 PM, bill lam  wrote:
> >>> hypothetical jqt can run on iOS but the main difficulty is still Apple
> >>> store policy.
> >>> 
> >>> 
> >>> On 20 Dec, 2016 1:30 am, "Kip Murray"  wrote:
> >>> 
> >>>> I have installed J805 on my ancient Windows 32 computer and am able to
> >> use
> >>>> Jqt.
> >>>> 
> >>>> My primary use of J is on my iPad Air.  Is there any news on that front?
> >>>> 
> >>>> --Kip Murray
> >>>> 
> >>>> On Monday, December 19, 2016, Eric Iverson 
> >>>> wrote:
> >>>> 
> >>>>> Installing J805 is strongly recommended for all users.
> >>>>> 
> >>>>> For some previous releases there were various reasons why some users
> >>>> would
> >>>>> hold of on moving to a new release. This is not the case for this
> >>>> release.
> >>>>> 
> >>>>> Everyone should move to 805 ASAP. It is in your interest and the
> >>>>> communities interest.
> >>>>> 
> >>>>> Install instructions have been significantly reworked. Taking time to
> >>>>> follow them carefully and providing feedback will help clean things
> >> up so
> >>>>> new users will have a smoother ride.
> >>>>> 
> >>>>> See www.jsoftware.com and click Download.
> >>>>> 
> >> --
> >>>>> For information about J forums see http://www.jsoftware.com/
> >> forums.htm
> >>>> 
> >>>> 
> >>>> 
> >>>> --
> >>>> Sent from Gmail Mobile
> >>>> --
> >>>> 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
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
> 
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
--
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

Re: [Jprogramming] J805 - install it!

2016-12-20 Thread &#x27;Bo Jacoby&#x27; via Programming
It works. Thank you! Bo.

 

Den 14:52 tirsdag den 20. december 2016 skrev 'Bo Jacoby' via Programming 
:
 
 

 I get the message: "Unable to run Package Manager, as you do not have access 
to the installation folder." 

    Den 12:31 tirsdag den 20. december 2016 skrev 'Bo Jacoby' via Programming 
:
 
 

 I don't know if I did install addons. I entered System/Installation/All-in-One 
- J Wikiand executed program j805_win32.exe. Shall it be redone?Thanks!Bo.
  
|  
|  
|  
|  |    |

  |

  |
|  
|  |  
System/Installation/All-in-One - J Wiki
  |  |

  |

  |

 
 

    Den 10:05 tirsdag den 20. december 2016 skrev bill lam 
:
 
 

 For the jqt route, one doesn't need j/iphone source code.
Download the jqt source and play with it.

Пн, 19 дек 2016, Xiao-Yong Jin написал(а):
> If you guys release the source code, anyone with a free apple ID account can 
> build and run without going through the app store.
> 
> https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYourApponDevices.html
> 
> 
> > On Dec 19, 2016, at 8:45 PM, bill lam  wrote:
> > 
> > I also heard beta test can deploy app without uploading to app store.
> > 
> > https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html
> > 
> > On 20 Dec, 2016 9:35 am, "Raul Miller"  wrote:
> > 
> >> Maybe you need to be charging a fee for copies sold through the Apple
> >> store, to cover those issues?
> >> 
> >> --
> >> Raul
> >> 
> >> 
> >> On Mon, Dec 19, 2016 at 8:17 PM, bill lam  wrote:
> >>> hypothetical jqt can run on iOS but the main difficulty is still Apple
> >>> store policy.
> >>> 
> >>> 
> >>> On 20 Dec, 2016 1:30 am, "Kip Murray"  wrote:
> >>> 
> >>>> I have installed J805 on my ancient Windows 32 computer and am able to
> >> use
> >>>> Jqt.
> >>>> 
> >>>> My primary use of J is on my iPad Air.  Is there any news on that front?
> >>>> 
> >>>> --Kip Murray
> >>>> 
> >>>> On Monday, December 19, 2016, Eric Iverson 
> >>>> wrote:
> >>>> 
> >>>>> Installing J805 is strongly recommended for all users.
> >>>>> 
> >>>>> For some previous releases there were various reasons why some users
> >>>> would
> >>>>> hold of on moving to a new release. This is not the case for this
> >>>> release.
> >>>>> 
> >>>>> Everyone should move to 805 ASAP. It is in your interest and the
> >>>>> communities interest.
> >>>>> 
> >>>>> Install instructions have been significantly reworked. Taking time to
> >>>>> follow them carefully and providing feedback will help clean things
> >> up so
> >>>>> new users will have a smoother ride.
> >>>>> 
> >>>>> See www.jsoftware.com and click Download.
> >>>>> 
> >> --
> >>>>> For information about J forums see http://www.jsoftware.com/
> >> forums.htm
> >>>> 
> >>>> 
> >>>> 
> >>>> --
> >>>> Sent from Gmail Mobile
> >>>> --
> >>>> 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
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
> 
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
--
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

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

[Jprogramming] code.jsoftware.com/wiki

2017-01-06 Thread &#x27;Bo Jacoby&#x27; via Programming
I tried to comment on http://code.jsoftware.com/wiki/Talk:Essays/FFT , but "do 
not have permission to create this page.". Can I get permission, please?
Thanks, Bo.
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] code.jsoftware.com/wiki

2017-01-06 Thread &#x27;Bo Jacoby&#x27; via Programming
I cannot login because:" You have cookies disabled. Please enable them and try 
again."
I do not know how to enable cookies.
 

Den 14:11 fredag den 6. januar 2017 skrev chris burke 
:
 
 

 Thanks. An account has been created for you, and the login details sent
separately.

On Fri, Jan 6, 2017 at 1:27 AM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

> I tried to comment on http://code.jsoftware.com/wiki/Talk:Essays/FFT ,
> but "do not have permission to create this page.". Can I get permission,
> please?
> Thanks, Bo.
> --
> 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

Re: [Jprogramming] Indices of a matrix

2017-01-11 Thread &#x27;Bo Jacoby&#x27; via Programming
   4%~a-4|a

 

Den 6:27 onsdag den 11. januar 2017 skrev Skip Cave 
:
 
 

 Ben, Jose, Raul, Roger,

Thanks so much for your efforts in providing various solutions to my index
problem.
I am continually amazed at the diversity of options that J's primitives
provide to approach problems.

Ben:
4$.$. i.3 4  NB. Unboxed using Sparse
NB. Wow! I would have never even thought of trying Sparse!

{i. each $ i. 3 4  NB.Boxed using Each
NB. Very similar to Roger's solution.

Jose:
>L:1@:{::@:(<"0)@:i. 3 4
NB.  Boxed. Whew! Lots of tacit stuff. Above my pay grade!

Roger:
{i.&.> 3 4  NB. Boxed, minimal, elegant.

Raul:
3 4 #: i. 3 4 NB. Unboxed using Encode

Skip Cave
Cave Consulting LLC

On Tue, Jan 10, 2017 at 5:05 PM, Skip Cave  wrote:

> Given a 3x4 matrix:
>
>
>
>  a =. i. 3 4
>
>  a
>
> 0 1  2  3
>
> 4 5  6  7
>
> 8 9 10 11
>
>
>
> I can get the horizontal indices:
>
>
>
>    4|a
>
> 0 1 2 3
>
> 0 1 2 3
>
> 0 1 2 3
>
>
>
>
>
> How do I get the vertical indices?
>
>
>
>  3?a  NB. The question-mark represents the unknown verb
>
> 0 0 0 0
>
> 1 1 1 1
>
> 2 2 2 2
>
>
>
> Ultimately, I want to design a verb bix, that will take a list of
> dimensions of any length, and generate boxed indices of the resulting
> array. The number of integers in each box will be the same as the rank of
> the array:
>
>
>
>
>  bix 10
>
> ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
>
> │0│1│2│3│4│5│6│7│8│9│
>
> └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘
>
>
>
>  bix 3 4
>
> ┌───┬───┬───┬───┐
>
> │0 0│0 1│0 2│0 3│
>
> ├───┼───┼───┼───┤
>
> │1 0│1 1│1 2│1 3│
>
> ├───┼───┼───┼───┤
>
> │2 0│2 1│2 2│2 3│
>
> └───┴───┴───┴───┘
>
>
>  bix 2 3 4
>
> ┌─┬─┬─┬─┐
>
> │0 0 0│0 0 1│0 0 2│0 0 3│
>
> ├─┼─┼─┼─┤
>
> │0 1 0│0 1 1│0 1 2│0 1 3│
>
> ├─┼─┼─┼─┤
>
> │0 2 0│0 2 1│0 2 2│0 2 3│
>
> └─┴─┴─┴─┘
>
> ┌─┬─┬─┬─┐
>
> │1 0 0│1 0 1│1 0 2│1 0 3│
>
> ├─┼─┼─┼─┤
>
> │1 1 0│1 1 1│1 1 2│1 1 3│
>
> ├─┼─┼─┼─┤
>
> │1 2 0│1 2 1│1 2 2│1 2 3│
>
> └─┴─┴─┴─┘
>
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] [JForum] sampling from a multivariate gaussian distribution

2017-01-11 Thread &#x27;Bo Jacoby&#x27; via Programming
NB. A generator of random numbers from a standard normal distribution
   gauss=. 3 : '+/(?-?)0$~6,y'
   gauss 5
1.44394 _0.23159 0.150841 0.499904 1.16614 

Den 18:26 onsdag den 11. januar 2017 skrev Brian Schott 
:
 
 

 Your example has 0 valued off-diagonal elements in sq, so there is no
covariance and 2 independent gaussians can be used.

But it your sg had non-zero off-diagonals then according to a very old
reference, if you can find lower triangular matrix c such that sg -:  c+/ .
*|:c then you can generate X=(c+/ . *Z)+mu where Z are standard normal and
your desired result is X .

I am assuming you have access to a standard normal random generator. One,
which I have not used is the verb normalrandom in stats/base/random.ijs .


-- 
(B=) <-my sig
Brian Schott
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] Explicit fib

2017-02-26 Thread &#x27;Bo Jacoby&#x27; via Programming
   (,+/ @(_2&{.))^:15(1)1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987

 

Den 22:29 søndag den 26. februar 2017 skrev Louis de Forcrand 
:
 

 Perhaps use the recursive definition; slower but possibly easiest to 
understand (you can sneak in an M. if you don't talk about computation speed).

fib=: 3 : 0 M.  NB. 0-indexed
 if. y <: 1 do. y
 else. (fib y-1) + fib y-2
 end.
)

Louis

> On 26 Feb 2017, at 20:37, Raul Miller  wrote:
> 
> Then perhaps something like this:
> 
> fib=:verb define
>  series=. 0 1
>  needed=. >./, y
>  while. needed >: #series do.
>    series=. series, +/_1 _2 { series
>  end.
>  y { series return.
> )
> 
> Thanks,
> 
> -- 
> Raul
> 
> 
> 
>> On Sun, Feb 26, 2017 at 1:42 PM, Linda A Alvord  
>> wrote:
>> I only know the one in my example.  1, 1, 2, 3, 5 ...
>> Next tern us tge sum of the previous two or in this case 8. It an infinite 
>> series.
>> 
>> Linda
>> 
>> -Original Message-
>> From: Programming [mailto:programming-boun...@forums.jsoftware.com] On 
>> Behalf Of Raul Miller
>> Sent: Sunday, February 26, 2017 1:03 PM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Explicit fib
>> 
>> Which english definition of fibonacci's series are you working with?
>> 
>> Thanks,
>> 
>> --
>> Raul
>> 
>> 
>> On Sun, Feb 26, 2017 at 12:48 PM, Linda A Alvord
>>  wrote:
>>> I have been working on finding an explicit definition for the Fibonacci
>>> series. (without tie)
>>> 
>>> 
>>> 
>>> fib 14
>>> 
>>> 5!:4 <'fib'
>>> 
>>> load 'debug'
>>> 
>>> dissect'fib 14'
>>> 
>>> 
>>> 
>>> To see the dissection, place cursor on  fib  and click right mouse.
>>> 
>>> 
>>> 
>>> I want a definition which will work for the youngest children.
>>> 
>>> 
>>> 
>>> Thanks for any ideas.  Linda
>>> 
>>> --
>>> 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
> --
> 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

Re: [Jprogramming] Explicit fib

2017-03-02 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi Linda
Understanding a program:
     _2&{.1 1 2 NB. the last two elements1 2
     +/@(_2&{.)1 1 2 NB. are added together3
     (,+/ @(_2&{.))1 1 2 NB. and the sum is appended to the rest1 1 2 3
     (,+/ @(_2&{.))^:14(1) NB. fourteen times1 1 2 3 5 8 13 21 34 55 89 144 233 
377 610 

Den 20:38 torsdag den 2. marts 2017 skrev Linda A Alvord 
:
 

 Joe, this has taken me a while because I like to understand something, at 
least a  little bit, before I respond.  I can't quite how this works.

    (,+/ @(_2&{.))^:14(1)
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610

You get an extra term, but I could define your verb.
  
  fibjb=: 13 :'}:(,[:+/ (_2&{.))^:y 1'
  fibjb 14
1 1 2 3 5 8 13 21 34 55 89 144 233 377

But I wish I could understand how it works as it looks so simple.

A tree didn't help much: 


  5!:4 <'fibjb'
      ┌─ 3                        
── : ─┴─ ,:'}:(,[:+/ (_2&{.))^:y 1'
  
Dissect seemed to withhold its secrets.  SO it's up to you to help me.'
  
  load 'debug'  
  dissect 'fibjb 14'
 
Thanks in advance.  Linda  

-Original Message-
From: Programming [mailto:programming-boun...@forums.jsoftware.com] On Behalf 
Of Joe Bogner
Sent: Monday, February 27, 2017 9:49 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Explicit fib

This is how I would approach it for young children -- attempting to follow your 
english description

fibJ =: 3 : 0

firstLast =. 1
secondLast =. 0
total =. 1

for_N. i. (y-1) do.

term =. (firstLast + secondLast)
secondLast =. firstLast
firstLast =. term

total =. total,term

end.
total
)
fibJ 15
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610

The definition is simpler if you just want the Nth number

fibJ =: 3 : 0

firstLast =. 1
secondLast =. 0

for_N. i. (y-1) do.

term =. (firstLast + secondLast)
secondLast =. firstLast
firstLast =. term
end.
term
)
fibJ 15
610



On Mon, Feb 27, 2017 at 9:16 AM, David Lambert  wrote:
>    fib3=: 13 :'}.1|.,''),(fib2 '',"_ 1":i.y,1'
>
>    ". fib3 6
> 0 1 1 2 3 5
>
>
> Let's reorganize by grouping all the strings to increase the sentence 
> legibility.
>
>    '),(fib2 ' ,"_ 1  ": ,. i. 7
> ),(fib2 0
> ),(fib2 1
> ),(fib2 2
> ),(fib2 3
> ),(fib2 4
> ),(fib2 5
> ),(fib2 6
>
> From here ravel, rotate by one position, finally discard the extra comma.
>
>
> On 02/27/2017 07:00 AM, programming-requ...@forums.jsoftware.com wrote:
>>
>> Date: Mon, 27 Feb 2017 05:01:34 -0500
>> From: "Linda A Alvord" 
>> To:
>> Subject: Re: [Jprogramming] Explicit fib
>> Message-ID: <000301d290e0$7ae35ac0$70aa1040$@net>
>> Content-Type: text/plain;      charset="utf-8"
>>
>> I like fib2 and things were going well but I hit a snag:
>>
>> ]W=:*i.2 2
>> 0 1
>> 1 1
>>        mp=:+/ . *
>>        fib2=:3 : '{. W&mp^:y 0 1'
>>    ". }:, (14 5$'(fib2'),"1 (' ',"1  ' ',"1 ":,.>:i.14),"1 '),'
>> 1 1 2 3 5 8 13 21 34 55 89 144 233 377
>>          fib3=: 13 :' ". }:, ((y,5)$'(fib2'),"1 (' ',"1  ' ',"1
>> ":,.>:i.y),"1 '),''
>> |domain error: fib2
>> |  {.W&mp    ^:y 0 1
>>    It doesn't like the fact that that the fib2 should still be just 
>> letters.
>>
>> It was fun anyway.  Linda
>
>
> --
> 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

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

Re: [Jprogramming] Complex functions visualization

2017-04-11 Thread &#x27;Bo Jacoby&#x27; via Programming
Consider drawing the complex plane such that 1 is upwards and i is to the 
right. Then complex conjugation correspond to left-right symmetry, which is 
more familiar than up-down symmetry. 
Bo.
 

Den 17:57 tirsdag den 11. april 2017 skrev Roger Hui 
:
 

 V. cool.


On Tue, Apr 11, 2017 at 8:39 AM, Andrew Nikitin  wrote:

> I read a book "Visual Complex Functions" by Elias Wegert.
>
> In it autor argues for so called phase portraits as a good way to visualize
> complex function of one complex variable. Each function value is
> represented by
> a pixel with a hue (which is an angular quantity) equal to function value's
> phase angle. He argues that the result provides a lot of information about
> function and even allows to restore analytic functions (up to a constant).
>
> The other 2 components of the colorspace, saturation and light, can be
> used to show lines of equal phase and equal magnitude. Author calls it
> "enhanced phase portrait". Interesting, that there is no level tracing.
> Lines appear as a byproduct of using a modified hue palette.
>
> I put up a script and couple of sample images on wiki. 'sq' utility
> generates
> unit square of complex numbers. Evaluate your choice of function on it and
> color each pixel with ccEnhPh and you have yourself a phase portrait to
> view
> with viewmat or save with writebmp.
>
> http://code.jsoftware.com/wiki/User:Andrew_Nikitin/Phase_portraits
>
> I think that if you like pretty pictures (and want to get some insight on
> complex function behavior), this technique provides a lot of bang for a
> very
> little buck.
>
>
> --
> 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

Re: [Jprogramming] matching & cancelling transactions

2017-04-12 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi Joe!
My favorite datastructure is ORDINAL FRACTIONS - the algebra of data 
  
|  
|   
|   
|   ||

   |

  |
|  
||  
ORDINAL FRACTIONS - the algebra of data
 This paper was submitted to the 10th World Computer Congress, IFIP 1986 
conference, but rejected by the referee  |   |

  |

  |

 
Your data are coded like this
10 Joe
20 Bob
30 Jane
01 blue
02 red
03 purple
11 1
11 -1
11 1
22 1
22 1
22 3
22 -1
22 -1
33 5
33 -2
33 2
(Written with double CRs because the mail program has a history of deleting my 
CRs).
Summation gives the result
10 Joe
20 Bob
30 Jane
01 blue
02 red
03 purple
11 1
22 3

33 5
I have not done the summation in J, but I'd like to do it.
Perhaps this helps you.
Bo.

 

Den 0:04 torsdag den 13. april 2017 skrev chris burke 
:
 

 Incidentally, for production code, I suggest starting by removing any sales
not matched in returns and vice versa, so that the matching algorithm is
applied only to potential matches.

On Wed, Apr 12, 2017 at 2:53 PM, chris burke  wrote:

> Great.
>
> In case you need more complicated handling of the "gray area"
> transactions, I believe they would be relatively few in number, so most of
> the time you could do the matching efficiently, then check for any keys
> with returns preceding sales. For those, setting aside the first such
> return and repeating should clear them quickly.
>
> Timing should be well under 1 second for a million records.
>
> On Wed, Apr 12, 2017 at 1:57 PM, Joe Bogner  wrote:
>
>> Just for completeness, I added a line that incorporates the sequence check
>> into the cancel logic. Works great
>>
>> NB. hui progressive index
>> NB. http://code.jsoftware.com/wiki/Essays/Progressive_Index-Of
>> oc=: i.~ (] - {) /:@/:
>> pi=: #@[ ({. i.&(,.oc) }.) [ i. ,
>>
>> NB. argument is 3-col table of seq,key,qty
>> NB. result is the unmatched transactions
>> matchtrans=: 3 : 0
>> msk=. 0<{:"1 y
>> sales=. msk#y
>> returns=. (-.msk)#y
>> ndx=. (}."1 sales) pi | }."1 returns
>> cancels=. ndx<#sales
>> NB. ensure cancel is after sale
>> cancels =. cancels *. (({."1 (<<(cancels)#ndx){sales) < ({."1
>> (cancels#returns)))
>> ((<<> )
>>
>>
>> On Wed, Apr 12, 2017 at 4:14 PM, Joe Bogner  wrote:
>>
>> > Chris, this looks promising. Thanks for sharing. It's nearly instant on
>> a
>> > million rows.
>> >
>> > Which row had a return before a transaction? seq 10 was an example of a
>> > partial return. The hypothetical customer returned 2 out of the 5
>> purchased
>> > prior. I added that example since technically per the original spec it
>> > wouldn't be cancelled out in this pass.  It's a gray area so I may be
>> able
>> > to use this approach, especially since I don't see how to incorporate
>> the
>> > time element into the progressive index.
>> >
>> > Thanks again
>> >
>> >
>> > On Wed, Apr 12, 2017 at 3:52 PM, chris burke 
>> wrote:
>> >
>> >> This might be done by comparing matrices of sales and returns. The
>> >> function
>> >> below seems to be close to what you want. It doesn't exactly match your
>> >> example, but your example has cases where returns are made before the
>> >> transactions. Was this intentional?
>> >>
>> >> The code should run faster than a looping solution.
>> >>
>> >> Code:
>> >>
>> >> NB. hui progressive index
>> >> NB. http://code.jsoftware.com/wiki/Essays/Progressive_Index-Of
>> >> oc=: i.~ (] - {) /:@/:
>> >> pi=: #@[ ({. i.&(,.oc) }.) [ i. ,
>> >>
>> >> NB. argument is 3-col table of seq,key,qty
>> >> NB. result is the unmatched transactions
>> >> matchtrans=: 3 : 0
>> >> msk=. 0<{:"1 y
>> >> sales=. msk#y
>> >> returns=. (-.msk)#y
>> >> ndx=. (}."1 sales) pi | }."1 returns
>> >> cancels=. ndx<#sales
>> >> ((<<> >> )
>> >>
>> >> Example:
>> >>
>> >>    dat=: ".;._2 (0 : 0)
>> >> 1 1 1
>> >> 2 1 _1
>> >> 3 1 1
>> >> 4 2 1
>> >> 5 2 1
>> >> 6 2 3
>> >> 7 2 _1
>> >> 8 2 _1
>> >> 9 3 5
>> >> 10 3 _2
>> >> 11 3 2
>> >> )
>> >>
>> >>    matchtrans dat
>> >> 3 1 1
>> >> 6 2 3
>> >> 9 3 5
>> >>
>> >>
>> >> On Wed, Apr 12, 2017 at 9:35 AM, Joe Bogner 
>> wrote:
>> >>
>> >> > I have a problem I'm trying to solve in different languages. I have a
>> >> > solution in SQL and also in kdb which largely resembles the SQL
>> >> solution.
>> >> > I'm curious what a J solution would look like. More specifically, I'm
>> >> > interested in picking the brains of others here to see if this type
>> of
>> >> > problem can be solved without looping (some form of scan?).
>> >> >
>> >> > EDIT: Initially I wrote this up thinking the J solution would
>> difficult,
>> >> > but it was actually fairly straightforward -- about 15 minutes, but
>> >> still
>> >> > would like to see if there are alternatives. If nothing else, maybe
>> an
>> >> > interesting problem to share.
>> >> >
>> >> > Example data:
>> >> >
>> >> > A store has a transaction log with a sequence for each transaction.
>> The
>> >> > transaction log records a key for a unique customer/item combination.
>> >> The
>> >> > transaction log records how many units were purchased or returned.

Re: [Jprogramming] matching & cancelling transactions

2017-04-13 Thread &#x27;Bo Jacoby&#x27; via Programming
Hi Louis.
Thanks for asking. I regret not knowing the answer.
An ordinal fraction is like an array in J, with minor differences.   
   - Arrays have names. Ordinal fractions have numbers. 
   - An array has a finite number of dimensions. An ordinal fraction has an 
infinite number of dimensions.
   - Arrays may have different shapes. All ordinal fractions have the same 
shape: 9 9 9 9 . . .
   - Arrays have zero-origin indexing (0 1 . . .  n). Ordinal fractions have 
one-origin indexing (1 2 3 4 5 6 7 8 9).    

   - Arrays have elements. Ordinal fractions do not have elements.
   - Arrays may have subarrays. All ordinal fractions have subordinate ordinal 
fractions. 
   - Array elements contain data. Any ordinal fraction may contain a data 
element.
Ordinal fractions were invented (by me) in 1980, but have had limited 
dissemination so far. I made programs in fortran and pascal and basic for 
manipulating ordinal fraction files, but I have not managed to do it in J. The 
programs were general, because the logic is in the data file and not in the 
program. I have been alone doing this. 
Thanks! Bo.


 

Den 20:08 torsdag den 13. april 2017 skrev Louis de Forcrand 
:
 

 Hi Bo,
This is cool.

As for the way you suggest using it here, isn't it equivalent to (without the 
first six rows of your data):

(~.@[ ,. +//.)/@|:
?

Louis

> On 12 Apr 2017, at 21:57, 'Bo Jacoby' via Programming 
>  wrote:
> 
> Hi Joe!
> My favorite datastructure is ORDINAL FRACTIONS - the algebra of data 
> 
> |  
> |  
> |  
> |  |    |
> 
>  |
> 
>  |
> |  
> |    |  
> ORDINAL FRACTIONS - the algebra of data
> This paper was submitted to the 10th World Computer Congress, IFIP 1986 
> conference, but rejected by the referee  |  |
> 
>  |
> 
>  |
> 
> 
> Your data are coded like this
> 10 Joe
> 20 Bob
> 30 Jane
> 01 blue
> 02 red
> 03 purple
> 11 1
> 11 -1
> 11 1
> 22 1
> 22 1
> 22 3
> 22 -1
> 22 -1
> 33 5
> 33 -2
> 33 2
> (Written with double CRs because the mail program has a history of deleting 
> my CRs).
> Summation gives the result
> 10 Joe
> 20 Bob
> 30 Jane
> 01 blue
> 02 red
> 03 purple
> 11 1
> 22 3
> 
> 33 5
> I have not done the summation in J, but I'd like to do it.
> Perhaps this helps you.
> Bo.
> 
> 
> 
>    Den 0:04 torsdag den 13. april 2017 skrev chris burke 
>:
> 
> 
> Incidentally, for production code, I suggest starting by removing any sales
> not matched in returns and vice versa, so that the matching algorithm is
> applied only to potential matches.
> 
>> On Wed, Apr 12, 2017 at 2:53 PM, chris burke  wrote:
>> 
>> Great.
>> 
>> In case you need more complicated handling of the "gray area"
>> transactions, I believe they would be relatively few in number, so most of
>> the time you could do the matching efficiently, then check for any keys
>> with returns preceding sales. For those, setting aside the first such
>> return and repeating should clear them quickly.
>> 
>> Timing should be well under 1 second for a million records.
>> 
>>> On Wed, Apr 12, 2017 at 1:57 PM, Joe Bogner  wrote:
>>> 
>>> Just for completeness, I added a line that incorporates the sequence check
>>> into the cancel logic. Works great
>>> 
>>> NB. hui progressive index
>>> NB. http://code.jsoftware.com/wiki/Essays/Progressive_Index-Of
>>> oc=: i.~ (] - {) /:@/:
>>> pi=: #@[ ({. i.&(,.oc) }.) [ i. ,
>>> 
>>> NB. argument is 3-col table of seq,key,qty
>>> NB. result is the unmatched transactions
>>> matchtrans=: 3 : 0
>>> msk=. 0<{:"1 y
>>> sales=. msk#y
>>> returns=. (-.msk)#y
>>> ndx=. (}."1 sales) pi | }."1 returns
>>> cancels=. ndx<#sales
>>> NB. ensure cancel is after sale
>>> cancels =. cancels *. (({."1 (<<(cancels)#ndx){sales) < ({."1
>>> (cancels#returns)))
>>> ((<<>> )
>>> 
>>> 
>>>> On Wed, Apr 12, 2017 at 4:14 PM, Joe Bogner  wrote:
>>>> 
>>>> Chris, this looks promising. Thanks for sharing. It's nearly instant on
>>> a
>>>> million rows.
>>>> 
>>>> Which row had a return before a transaction? seq 10 was an example of a
>>>> partial return. The hypothetical customer returned 2 out of the 5
>>> purchased
>>>> prior. I added that example since technically per the original spec it
>>>> wouldn't be cancelled out in this pass.  It's a gray area so I may be
>>> able
>>>> to use this approach, e

Re: [Jprogramming] Complex Numbers

2017-08-01 Thread &#x27;Bo Jacoby&#x27; via Programming
  _8^%3
 

Den 20:37 mandag den 31. juli 2017 skrev Skip Cave 
:
 

 1 j. %:3    NB. I Should have looked at the bottom part of the dictionary
closer!

Roger said: " j. plays the same role for complex numbers as - for integers
and % for rational numbers.
​"​


Hmmm... "% for rational numbers"  What does that mean? Let's see...

    %2r3

3r2


    %123456r78901

78901r123456            NB. Cool! I didn't know that!


Skip

Skip Cave
Cave Consulting LLC

On Mon, Jul 31, 2017 at 1:22 PM, Roger Hui 
wrote:

> Ken Iverson invented j. and IMO is a masterstroke which separates him from
> mere mortals.  j. plays the same role for complex numbers as - for integers
> and % for rational numbers.
>
> See section 8 of *Some Exercises in APL Language Design
> *.
>
>
>
>
> On Mon, Jul 31, 2017 at 11:13 AM, Kenneth Lettow 
> wrote:
>
> > 1 j. %:3
> >
> > On Mon, Jul 31, 2017 at 2:10 PM, Skip Cave 
> > wrote:
> >
> > > How can I create the complex number  1 i (sqrt 3)  in J
> > >
> > > Several tries didn't work:
> > >
> > >
> > >
> > >    1j%:3
> > >
> > > |ill-formed number
> > >
> > >    a =: %:3
> > >
> > >    1ja
> > >
> > > |ill-formed number
> > >
> > >    1j(%:3)
> > >
> > > |ill-formed number
> > >
> > >      %:3
> > >
> > > 1.73205
> > >
> > >    1j1.73205
> > >
> > > 1j1.73205      NB. This works, but it isn't very elegant.
> > >
> > >                    NB.  I have to copy/paste the square root as text.
> > >
> > >
> > >
> > >
> > > Skip Cave
> > > --
> > > 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
>
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] Fractional parts

2017-08-06 Thread &#x27;Bo Jacoby&#x27; via Programming
1&|  works perfectly
 

Den 9:19 søndag den 6. august 2017 skrev Martin Kreuzer 
:
 

 In easy steps (and for further reference) ...

 From these test data (two floats, two integers, different signs), to 
get the fractional parts

    v=. 2.25 _8.11 16 _3

simply taking the Residue (when dividing by 1) doesn't work (error at 
negative float position)

    1|v
0.25 0.89 0 0

So first get Magnitude

    | v
2.25 8.11 16 3

then take Residue

    1 | (| v)
0.25 0.11 0 0

then get the sign right (see Raul's remark below)

    (*v) * (1 | | v)
0.25 _0.11 0 0

and put it as verb (fp), written as a fork

    fp=. * * 1||
    fp v
0.25 _0.11 0 0

-M

At 2017-08-06 02:14, you wrote:

>Eh... but that's wrong.  You can't add any integer to 0.542857 to 
>get _0.542857.
>
>If you want signed fractions, you'd need something like (*@] * (| |))
>
>Thanks,
>
>--
>Raul
>
>
>On Sat, Aug 5, 2017 at 10:01 PM, 'Pascal Jasmin' via Programming
> wrote:
> > combining other answers we get the cute:
>
> > 1 (| |)  _0.542857 _1.1875 1.96552 2.92308 4.13043 5.7 7.82353 
> 10.8571 15.5455 23.75
>
>
>
>
> > 
> > From: Bill 
> > To: "programm...@jsoftware.com" 
> > Sent: Saturday, August 5, 2017 8:30 PM
> > Subject: Re: [Jprogramming] Fractional parts
>
>
>
> > this also depends on what do you expect for negative numbers.
>
> > Sent from my iPhone
>
> > On 6 Aug, 2017, at 7:35 AM, Skip Cave  wrote:
>
> >> Oops! i meant:
> >>
> >> How does one find the fractional parts of a vector of floating point
> >> numbers?
> >>
> >> 0.542857 1.1875 1.96552 2.92308 4.13043 5.7 7.82353 10.8571 15.5455 23.75
> >> 41.8 114 247
> >>
> >> i want:
> >> 0.542857 0.1875 0.96552 0.92308 0.13043 0.7 0.82353 0.8571 5.5455 0.75 0.8
> >> 0 0
> >>
> >> (Last two integers have zero fractional part.)
> >>
> >>
> >> Skip Cave
> >> Cave Consulting LLC
> >>
> >> On Sat, Aug 5, 2017 at 6:30 PM, Skip Cave  wrote:
> >>
> >>> How does one find the fractional parts of a vector of floating point
> >>> numbers?
> >>>
> >>> 0.542857 1.1875 1.96552 2.92308 4.13043 5.7 7.82353 10.8571 15.5455 23.75
> >>> 41.8 114 247
> >>>
> >>> i want:
> >>> 0.542857 0.1875 0.96552 0.92308 0.13043 0.7 0.82353 0.8571 
> 5.5455 0.75 0.8
> >>> 114 247
> >>>
> >>> Skip
> >>>
> >>> Skip Cave
> >>> Cave Consulting LLC
> >> --
> >> 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
>--
>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

Re: [Jprogramming] Fractional parts

2017-08-08 Thread &#x27;Bo Jacoby&#x27; via Programming
The integer part  a  and the fractional part  b  of a number  x  is such that 
x=a+b and  a  is an integer and   0<:b  and  b<1 . I do know of no use of a 
"negative fractional part".  

Den 20:39 tirsdag den 8. august 2017 skrev Raul Miller 
:
 

 I think we've mostly been using the wiki for live documents. (I'm not
sure what all would be involved in changing the phrase book.)

Thanks,

-- 
Raul


On Tue, Aug 8, 2017 at 2:35 PM, Skip Cave  wrote:
> It looks like we have a reliable solution to find a fractional part of a
> floating point number, while maintaining the sign:
>
>    v
>
> _2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
>
>    fp=. * * 1||    NB. Thanks to Martin
>
>    fp v
>
> _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
>
>
> Credit should also go to the people who suggested the building blocks, e.g.
>
> (1|y) Raul  --  (1||y) Pascal  --  (*y) Raul
>
> It is also nice to have the companion verb - integer part:
>
>    ip=: * * <.@|      NB. Thanks to Louis
>
>    ip v
>
> _2 _5 _11 13 13 13 12
>
>
> I have needed these functions more than once in my enginering work. I
> believe that these two verbs need to be inserted somewhere in the "Numbers"
> section of the J Phrases doc. Maybe under "8A-Numbers & Counting", or
> 8C-Representations", or "8D-Arithmetic".
>
>
> How do we get them in the document? What section do they fit the best in?
> Can I edit the Phrases doc?
>
> Skip Cave
> Cave Consulting LLC
>
>
>
>>
>>
> --
> 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

Re: [Jprogramming] Fractional parts

2017-08-09 Thread &#x27;Bo Jacoby&#x27; via Programming
v=(<.v)+(1|v) NB. number = integer part + fractional part? Yes!
1 1 1 1 1 1 1 

Den 7:00 onsdag den 9. august 2017 skrev Don Guinn :
 

 True for 32 bit integers, but for 64 bit j integers and floats are the same
size.

On Aug 8, 2017 10:48 PM, "Skip Cave"  wrote:

> Don,
>
> You're right. Your approach achieves the same result when re-combining the
> fractional and integer part:
>
> ]v=:2%(3r19-%1 2 3 245 246 247 248)
>
>    ]'i f'=:|:0 1#:v
>
> _3 _6 _12 13 13 13 12
>
> 0.625 0.153846 0.6 0.0027933 0.00139082 0 0.998621
>
> i
>
> _3 _6 _12 13 13 13 12
>
> f
>
> 0.625 0.153846 0.6 0.0027933 0.00139082 0 0.998621
>
> v = i+f
>
> 1 1 1 1 1 1 1
>
>
> However,
>
>
>    datatype f
>
> floating
>
>    datatype i
>
> floating
>
>
> Where as the original fp/ip verbs give:
>
>
>    datatype fpv
>
> floating
>
>    datatype ipv
>
> integer
>
>
> So either approach will work, but ip returns integers, while your approach
> returns floats in both i & f cases. The fact that I originally called the
> verb the "integer part" probably led to the initial integer solution from
> the group.
>
>
> I'm not sure what advantages either approach would have, other than a space
> savings for pure integers.
>
>
> Skip
>
> Skip Cave
> Cave Consulting LLC
>
> On Tue, Aug 8, 2017 at 8:04 PM, Don Guinn  wrote:
>
> > ​There are many ways to handle the fractional part of a number, depending
> > on the problem at hand. The real difficulty seems to be handling negative
> > numbers. I like this, which rounds down negative numbers. But others
> might
> > want a different way.
> >
> >    ]'i f'=:|:0 1#:1.2 3.7 _2.1
> >  1  3  _3
> > 0.2 0.7 0.9
> >    i
> > 1 3 _3
> >
> >    f
> > 0.2 0.7 0.9
> >    i+f
> > 1.2 3.7 _2.1​
> >
> > On Tue, Aug 8, 2017 at 3:56 PM, Skip Cave 
> wrote:
> >
> > > The purpose of the "negative fractional part" is to satisfy the
> identity
> > > condition when the two parts are added back together:
> > >
> > >    ]v=:2%(3r19-%1 2 3 245 246 247 248)  NB. Create some long fractional
> > > parts.
> > >
> > > _2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
> > >
> > >
> > > fp=. * * 1||    NB. The fractional part verb
> > >
> > > ip=: * * <.@|  NB. The integer part verb
> > >
> > >
> > > ]fpv =: fp v    NB. Save the fractional part
> > >
> > > _0.375 _0.846154 _0.4 0.0027933 0.00139082 0 0.998621
> > >
> > >
> > > ]ipv =: ip v    NB. Save the integer part
> > >
> > > _2 _5 _11 13 13 13 12
> > >
> > >
> > >
> > > ]sm =: ipv + fpv  NB. Add the two parts back together
> > >
> > > _2.375 _5.84615 _11.4 13.0028 13.0014 13 12.9986
> > >
> > >
> > >  NB. The result of adding the two parts should be identical to the
> > original
> > > vector.
> > >
> > >
> > > sm = v
> > >
> > > 1 1 1 1 1 1 1
> > >
> > > Skip Cave
> > > Cave Consulting LLC
> > >
> > > On Tue, Aug 8, 2017 at 2:14 PM, 'Bo Jacoby' via Programming <
> > > programm...@jsoftware.com> wrote:
> > >
> > > > The integer part  a  and the fractional part  b  of a number  x  is
> > such
> > > > that x=a+b and  a  is an integer and  0<:b  and  b<1 . I do know of
> no
> > > use
> > > > of a "negative fractional part".
> > > >
> > > >    Den 20:39 tirsdag den 8. august 2017 skrev Raul Miller <
> > > > rauldmil...@gmail.com>:
> > > >
> > > >
> > > >  I think we've mostly been using the wiki for live documents. (I'm
> not
> > > > sure what all would be involved in changing the phrase book.)
> > > >
> > > > Thanks,
> > > >
> > > > --
> > > > Raul
> > > >
> > > >
> > > > On Tue, Aug 8, 2017 at 2:35 PM, Skip Cave 
> > > wrote:
> > > > > It looks like we have a reliable solution to find a fractional part
> > of
> > > a
> > > > > floating point number, while maintaining the sign:
> > > > >
> > > > >    v
>

Re: [Jprogramming] Multidimensional Root Finding with Newton Solver

2017-08-10 Thread &#x27;Bo Jacoby&#x27; via Programming
Solving many algebraic equations in many unknowns can be done by eliminating 
the unknowns one by one obtaining many algebraic equations in one unknown each, 
and then solving these equations numerically.
Example: Two equations in two unknowns. 0 = (x^2)+(y^2)-16 = (y-2) . 
0 = y-2 = y(y-2) = (y^2)-(2*y)= ((x^2)+(y^2)-16)-((y^2)-(2*y)) = (x^2)+(2*y)-16 
 = ((x^2)+(2*y)-16)-2*(y-2) = (x^2)-12
Now the system 0 = (x^2)+(y^2)-16 = (y-2)  is reduced to 0 = (x^2)-12 = (y-2)
These are solved: 
p. _12 0 1 p. _2 1

The method is general, but  cumbersome for equations of high degree in many 
unknowns. 
Thanks. Bo. 

Den 0:06 fredag den 11. august 2017 skrev Louis de Forcrand 
:
 

 I find it interesting that N-R works for vectors and complex functions (and 
mixes of both). Just replace all those scalar functions by their vector 
equivalents:

vn=: 1 : '- n * u %. u D.1'

I added a scaling factor; it makes the convergence slower, but it fixes 
problems due to precision-loss.

It works reasonably well:

  f=: ^&0 1 - 1 2 ^~ {.
  f vn 0.1^:1e3 ] 0 0
1 1

Louis

> On 10 Aug 2017, at 13:07, Martin  wrote:
> 
> Hi there,
> 
> J looks very interesting. I have no previous experience with array
> languages and, being curious, started to experiment.  Now, I would
> like to solve a system of non-linear equations. I could only examples
> solving single equations like this one:
> 
>  N=: 1 : '- u % u d. 1'  NB. Adverb implementing Newton-Raphson iteration.
>  (_2 + *:) N^:_ ]1        NB. Find root of “0 = _2+x^2”, starting guess of 
>“1”.
> 
> Is it also possible to solve a system of equation like the following
> one in a similar elegant manner?
> 
>  f1(x) = a*(1-x1)
>  f2(x) = b*(x2-x1^2)
> 
> Example from 
> https://www.gnu.org/software/gsl/doc/html/multiroots.html#examples
> 
> Thanks for any ideas!
> -Martin
> 
> --
> 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

Re: [Jprogramming] Integer-floating type change for large numbers in j805 and j806

2017-08-12 Thread &#x27;Bo Jacoby&#x27; via Programming
Don Guinn wrote: "But few things need precision beyond 16 significant digits". 
Well, just computing the determinant of a 4*4 matrix of 4-figure integers 
require 16 digit precision! 

Den 1:52 lørdag den 12. august 2017 skrev Don Kelly :
 

 Right on!

In most numerical operations on a  computer, there is an inherent 
propagation of errors (in fact Numerical analysis texts spend a lot of 
effort on ways to reduce such errors) and 16 or more digits don't 
provide precision greater than  that of the input data but do reduce the 
computational  fuzz to an insignificant level. The ideal kit for a 
student using a hand calculator would be a strip of electrical tape to 
cover the extra digits.

Don Kelly


On 2017-08-11 6:33 AM, Don Guinn wrote:
> We too often assume that calculations carried out to 16 significant digits
> are accurate when the input may not be known to less than 2 or 3
> significant digits. We can calculate the distance to the moon accurately to
> the wavelength of visible light in IEEE floating point. We can calculate
> the national debt to the penny. Maybe calculating relativistic effects on a
> satellite orbiting the earth might exceed IEEE floating point. But few
> things need precision beyond 16 significant digits.
>
> On Thu, Aug 10, 2017 at 11:14 PM, Don Kelly  wrote:
>
>> isn't an advantage of APL and J that the person writing a
>> program/app/whatever, doesn't  have to deal with the distinctions between
>> integer and damn near integer  within the limitations of the computer
>> binary resolution?. In most cases this isa good thing because close enough
>> -given the +/- of data input is sufficient for the idiot box to decide. J
>> moves away from C/C++/ and other languages which often seem to be
>> emphasizing stuff that Iverson tried to eliminate in APL and J . Muh of
>> that stuff is something that can be handled by the idiot box so that:
>>
>> Problem-->basic analysis--. coding that fits the analysis rather than the
>> details( users aim at the essentials rather than the details- "/I  want the
>> answer and I dont care about what is involved in the background of %,*
>> */
>>
>> The discussion below deals with representation of numeric values being
>> floating point or integer when pushing the limits-IS IT IMPORTANT IN THE
>> REAL WORLD unless  you have a Cray in the back bedroom?
>>
>> Old fart expressing opinions
>>
>> Don Kelly
>>
>> On 2017-08-10 6:27 PM, Bill wrote:
>>
>>> I suspect J interpreter didn't has the knowledge  that the original
>>> string had been .3
>>> with .3 because what J saw was the floating point result of parsing by c
>>> library. Ieee floating point has 15 to 16 significant digits so that 1e16
>>> and 1e16-1 is the same number.
>>>
>>> Perhaps one could use long double to parse number on J64.
>>>
>>> Sent from my iPhone
>>>
>>> On 10 Aug, 2017, at 3:48 AM, Henry Rich  wrote:
>>>
>>> Quite right.
 Henry Rich

 On Aug 9, 2017 20:46, "Raul Miller"  wrote:

 Well, since it's encoded as an integer (which I would have noticed if
> I had read Bob Therriault's original post more closely), and not [like
> I was thinking] a float, I agree that dropping the .3 is better than
> adding a 1.
>
> That said, I guess we also should not object too loudly if
> .3 were instead encoded the same as
> +0.3 gets encoded.
>
> Thanks,
>
> --
> Raul
>
> On Wed, Aug 9, 2017 at 3:25 PM, Henry Rich 
> wrote:
>
>> Surely integer 999...9 is a better value than 1000...0 .
>>
>> Henry Rich
>>
>> On Aug 9, 2017 18:33, "Raul Miller"  wrote:
>>
>> It's not a bug, it's an artifact of the 64 bit floating point standard.
>>>    2 ^.
>>> 53.1508
>>>
>>> https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats
>>>
>>> The binary64 format has 53 binary digits or 15.95 decimal digits. This
>>> means ".16#'9' cannot be represented exactly using this format.
>>>
>>> And, we do not use exact representation of large numbers by default
>>> because that's too slow for large datasets. Put differently, if you
>>> want exact representation and are willing to take the performance hit,
>>> you should specify that. For example: ".'x',~16#'9' or
>>> ".'3r10+','x',~16#'9'
>>>
>>> Thanks,
>>>
>>> --
>>> Raul
>>>
>>> On Wed, Aug 9, 2017 at 12:05 PM, Henry Rich 
>>>
>> wrote:
>> This is a bug,  since 999...9.3 should become 999...9 rather than
>>> 100...0.
>>>
 I'm away from home now,  but I think what's happening is this:

 999...9 is converted to integer

 . is encountered and turns it to float

 It's rounded to the nearest float which is 100...0

 As a final step the JE checks to see if the value is exactly
 integral,
 which it is,  and it is

Re: [Jprogramming] Integer-floating type change for large numbers in j805 and j806

2017-08-14 Thread &#x27;Bo Jacoby&#x27; via Programming
The value of a partially known oil reserve could be reported like this: 
$100*10^(±1)  

Den 20:26 søndag den 13. august 2017 skrev Jimmy Gauvin 
:
 

 It gets even better with blind faith put into "algorithms" :

A nice read on the subject can be found in Cathy O'Neil's book:

https://weaponsofmathdestructionbook.com/

On Sun, Aug 13, 2017 at 10:17 AM, Don Guinn  wrote:

> What bothers me is that even though the source of data is unreliable, once
> run through a computer program people tend to believe that now the results
> are very accurate. One particular measure is oil reserves in the USA and
> world. We don't even know within a power of 10 what is out there. Do we
> include various methods of recovery like secondary, tertiary, various
> injection methods in our estimates? What fields being explored now may
> produce? We only have rough estimates on the size of fields. Yet oil
> companies have to report to the government the value of these reserves to
> the dollar.
>
> On Sat, Aug 12, 2017 at 8:43 PM, Don Kelly  wrote:
>
> > I think that Don Guinn was referring to the fact that the output results
> > from input of n sig figs will not be good to anything better than n  sig
> > figs. You have pointed out limits in  the representation of base 10
> > integers in a base 2 system. In fact, the results of multiplying 2 4
> digit
> > numbers might result in an overflow or conversion to float with
> truncation.
> >
> > Don Kelly
> > On 2017-08-12 12:19 PM, 'Bo Jacoby' via Programming wrote:
> >
> >> Don Guinn wrote: "But few things need precision beyond 16 significant
> >> digits". Well, just computing the determinant of a 4*4 matrix of
> 4-figure
> >> integers require 16 digit precision!
> >>
> >>      Den 1:52 lørdag den 12. august 2017 skrev Don Kelly  >:
> >>
> >>  Right on!
> >>
> >> In most numerical operations on a  computer, there is an inherent
> >> propagation of errors (in fact Numerical analysis texts spend a lot of
> >> effort on ways to reduce such errors) and 16 or more digits don't
> >> provide precision greater than  that of the input data but do reduce the
> >> computational  fuzz to an insignificant level. The ideal kit for a
> >> student using a hand calculator would be a strip of electrical tape to
> >> cover the extra digits.
> >>
> >> Don Kelly
> >>
> >>
> >> On 2017-08-11 6:33 AM, Don Guinn wrote:
> >>
> >>> We too often assume that calculations carried out to 16 significant
> >>> digits
> >>> are accurate when the input may not be known to less than 2 or 3
> >>> significant digits. We can calculate the distance to the moon
> accurately
> >>> to
> >>> the wavelength of visible light in IEEE floating point. We can
> calculate
> >>> the national debt to the penny. Maybe calculating relativistic effects
> >>> on a
> >>> satellite orbiting the earth might exceed IEEE floating point. But few
> >>> things need precision beyond 16 significant digits.
> >>>
> >>> On Thu, Aug 10, 2017 at 11:14 PM, Don Kelly  wrote:
> >>>
> >>> isn't an advantage of APL and J that the person writing a
> >>>> program/app/whatever, doesn't  have to deal with the distinctions
> >>>> between
> >>>> integer and damn near integer  within the limitations of the computer
> >>>> binary resolution?. In most cases this isa good thing because close
> >>>> enough
> >>>> -given the +/- of data input is sufficient for the idiot box to
> decide.
> >>>> J
> >>>> moves away from C/C++/ and other languages which often seem to be
> >>>> emphasizing stuff that Iverson tried to eliminate in APL and J . Muh
> of
> >>>> that stuff is something that can be handled by the idiot box so that:
> >>>>
> >>>> Problem-->basic analysis--. coding that fits the analysis rather than
> >>>> the
> >>>> details( users aim at the essentials rather than the details- "/I
> want
> >>>> the
> >>>> answer and I dont care about what is involved in the background of %,*
> >>>> */
> >>>>
> >>>> The discussion below deals with representation of numeric values being
> >>>> floating point or integer when pushing the limits-IS IT IMPORTANT IN
> THE
> >>>> REAL WORLD unless  you have a Cray in the

Re: [Jprogramming] "n-volume" of an "n-sphere"

2017-08-18 Thread &#x27;Bo Jacoby&#x27; via Programming
David, you ment to write "Largest spheres with unit radius found in 
dimensionality near five and a quarter."

 

Den 4:10 fredag den 18. august 2017 skrev David Lambert 
:
 

 Largest spheres found in dimensionality near five and a quarter.

Beautiful mathematics, and need string theory limit itself to integral 
dimensions?

    boxdraw_j_ 1
    load'~addons/math/misc/amoeba.ijs'
    sphvol=: (1p1&^%!)@-:@] * ^
    g=: -@:(1&sphvol)
    g amoeba(<16)Y=:2 1$4.1 5.8
+---++
|5.25692|_5.2|
+---++


On 08/16/2017 08:00 AM, programming-requ...@forums.jsoftware.com wrote:
> Date: Tue, 15 Aug 2017 19:33:09 +
> From: Ben Gorte - CITG
> To:"programm...@jsoftware.com"  
> Subject: Re: [Jprogramming] "n-volume" of an "n-sphere"
> Message-ID:
>     <5bd81dcc576258458ebbacd3072fdf913a525...@srv384.tudelft.net>
> Content-Type: text/plain; charset="us-ascii"
>
> A little surprise (to me) was
>    plot 1 sphvol i.30
> (for example)
>
> Can you predict it?
>
> greetings,
> Ben
> 
> From: Programming [programming-boun...@forums.jsoftware.com] on behalf of 
> Raul Miller [rauldmil...@gmail.com]
> Sent: Tuesday, August 15, 2017 19:55
> To: Programming forum
> Subject: [Jprogramming] "n-volume" of an "n-sphere"
>
>    sphvol=: (1p1&^%!)@-:@] * ^
>    1 sphvol 3
> 4.18879
>    1 sphvol i.7
> 1 2 3.14159 4.18879 4.9348 5.26379 5.16771
>
> Left argument is the radius of the "n-sphere".
>
> Right argument is the number of dimensions.
>
> I put "n-volume" in quotes, because if the dimension is 2 (for
> example), the "n-volume" is what we call the area of the circle. (And
> if the dimension is 1 that "n-volume" is the length of a line
> segment).
>
> Anyways, I stumbled across this and thought it might be interesting
> for someone else.
>
> Thanks,
>
> --
> Raul

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

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

Re: [Jprogramming] Puzzling result

2017-09-07 Thread &#x27;Bo Jacoby&#x27; via Programming
Elementary linear algebra breaks down for so-called ill-conditioned problems 
needing more precision than is provided by standard floating point numbers. 
Condition number
  
|  
|   |  
Condition number
 The condition number is an application of the derivative, and is formally 
defined as the value of the asymptotic...  |  |

  |

 
 

Den 18:35 torsdag den 7. september 2017 skrev Marshall Lochbaum 
:
 

 Primality testing is a much less common use case than you think, and in
fact I'm not aware of any use for extended-precision integers outside of
recreational mathematics (I guess you can count cryptography, but anyone
using extended-precision integers instead of large fixed-width integers
for that falls squarely on the recreational side as well). It would be a
poor choice to severely degrade J's performance to help out people doing
Project Euler problems.

Marshall

On Thu, Sep 07, 2017 at 12:54:58PM +0100, Rob B wrote:
> Thanks Raul, I am familiar with these ideas, and using x: is almost a reflex 
> now.
> 
> I feel that to protect the new J user, mod should convert to extended 
> precision automatically or issue an warning message. Giving tha answer zero 
> is very misleading.
> 
> PS I am not so concerned with small numbers and measurability as with large 
> numbers and primality. Heisenberg's Uncertainty Principle is not usually an 
> issue for me :)
> 
> Ragards, Rob.
> 
> > On 7 Sep 2017, at 11:32, Raul Miller  wrote:
> > 
> > The answer, oddly enough, is: yes.
> > 
> > The philosophical arguments are buried here:
> > 
> > https://en.wikipedia.org/wiki/Accuracy_and_precision
> > 
> > The technical issues are buried here:
> > 
> > https://en.wikipedia.org/wiki/IEEE_754
> > 
> > That said, if you have reason to be using numbers which are precise
> > beyond anyone's ability to measure (and keep in mind Heisenberg
> > Uncertainty as one of the practical limits on measurability), you
> > should probably be using extended precision numbers (123x instead of
> > 123). This will give you exact results in exchange for a performance
> > penalty.
> > 
> > Thanks,
> > 
> > -- 
> > Raul
> > 
> > 
> >> On Thu, Sep 7, 2017 at 4:42 AM, Rob B  wrote:
> >> On reflection my real question is; should mod suddenly and without warning 
> >> give the wrong answer when a number gets suffiently large? I have been 
> >> caught by this many times. The incorrect answer zero is problematic as it 
> >> suggests divisibility.
> >> 
> >> Apologies if this has all been discussed before.
> >> 
> >> Regards, Rob Burns.
> >> 
> >> 
> >> 
> >>> On 6 Sep 2017, at 09:11, Rob B  wrote:
> >>> 
> >>> Thanks,
> >>> 
> >>> I now see it's reasonable for ^ to convert to flost and *: to remain 
> >>> exact.
> >>> 
> >>> The other discrepancy is probably due to my old version, iPad 701.
> >>> 
> >>> Regards, Rob Burns.
> >>> 
>  On 5 Sep 2017, at 17:48, HenryRich  wrote:
>  
>  datatype 47^2
>  
>  floating
>  
>  
>  So
>  
>  (n^2) | 5729082486784839
>  
>  is promoted to float, and loses precision.  Same when the big number is 
>  extended - it's converted to float.
>  
>  For
>  
>  (x: n^2) | 5729082486784839
>  
>  I get 147 as the result.
>  
>  Henry Rich
>  
> > On 9/5/2017 12:41 PM, Rob B wrote:
> > Could someone explain this please?
> > 
> > n=.14
> > n
> > 14
> > (*: n) | 5729082486784839
> > 147
> > 196 | 5729082486784839
> > 147
> > (n^2) | 5729082486784839
> > 0
> > (n^2) | 5729082486784839x
> > 0
> > (x: n^2) | 5729082486784839
> > 0
> > (x: n^2) | 5729082486784839x
> > 147
> > 
> > 
> > Regards, Rob Burns
> > --
> > 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
> > --
> > 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

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

Re: [Jprogramming] Puzzling result

2017-09-08 Thread &#x27;Bo Jacoby&#x27; via Programming

   %2 NB. floating
0.5
   x: %2 NB. extended
1r2
   %1j1 NB. floating
0.5j_0.5
   x: %1j1 NB. why not extended?
|domain error
| x:%1j1

 

Den 3:53 lørdag den 9. september 2017 skrev Don Kelly :
 

 It appears that the verb   ^  may be a large part of the problem (as in 
14^2). Check NuVoc  /vocabulary/Numeric Precision  and go the table for 
different verbs . This and the division may be floating point in this case

_

^ ^. -: % %. inexact (complex if needed),

preserves extended and rational
if result is exact

_

Don Kelly

On 2017-09-08 1:36 AM, Raul Miller wrote:
> No: integers do not automatically get converted to extended precision.
>
> Integers simply have sufficient precision for this example.
>
> Thanks,
>

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

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

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread &#x27;Bo Jacoby&#x27; via Programming
100 12#:166.7 NB. feet and inches
13 10.7
 100 12 16#:16*166.7 NB. feet and inces and sixteenth inches
13 10 11.2
 

Den 19:10 mandag den 18. september 2017 skrev Brian Schott 
:
 

 My car is 166.7 inches long according to the specs.
Car cover coverages are measured in feet and inches.

To compute how many feet and inches long my car is I used the following
calculations.

  166.7%12
13.8917
  (-<.)166.7%12
0.891667
  12x *(-<.)166.7%12  NB. the x is not required, imo
10.7

Which seems to suggest the car is 13 feet 10.7 inches long, right?

Being a little annoyed at how difficult that calculation seems I decided to
try to also see how many 16ths of an inch is added, so I did the following
which seems to suggest between 11 and 12 sixteenths.

  16x * (-<.) 12x *(-<.)166.7%12  NB. again, x is extra
11.2

I wonder if there is an easier way to do this, which in my recollection
seems to be in the wheelhouse of Ian's Tabula or its brethren. I had
expected #: to be involved in the calculations, but could not find such.


-- 
(B=)
​​
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-19 Thread &#x27;Bo Jacoby&#x27; via Programming
   _ 12 10#:10*166.7
13 10 7
 

Den 1:46 tirsdag den 19. september 2017 skrev Raul Miller 
:
 

 0 12 10 #: 10 * y

Or just 0 12 #: y, since the result gets displayed as a decimal...

Thanks,

-- 
Raul

On Mon, Sep 18, 2017 at 5:17 PM, Skip Cave  wrote:
> How do you get feet, inches, and tenths of inches?
>
> Skip Cave
> Cave Consulting LLC
>
> On Mon, Sep 18, 2017 at 2:31 PM, 'Bo Jacoby' via Programming <
> programm...@jsoftware.com> wrote:
>
>> 100 12#:166.7 NB. feet and inches
>> 13 10.7
>>  100 12 16#:16*166.7 NB. feet and inces and sixteenth inches
>> 13 10 11.2
>>
>>
>>    Den 19:10 mandag den 18. september 2017 skrev Brian Schott <
>> schott.br...@gmail.com>:
>>
>>
>>  My car is 166.7 inches long according to the specs.
>> Car cover coverages are measured in feet and inches.
>>
>> To compute how many feet and inches long my car is I used the following
>> calculations.
>>
>>  166.7%12
>> 13.8917
>>  (-<.)166.7%12
>> 0.891667
>>  12x *(-<.)166.7%12  NB. the x is not required, imo
>> 10.7
>>
>> Which seems to suggest the car is 13 feet 10.7 inches long, right?
>>
>> Being a little annoyed at how difficult that calculation seems I decided to
>> try to also see how many 16ths of an inch is added, so I did the following
>> which seems to suggest between 11 and 12 sixteenths.
>>
>>  16x * (-<.) 12x *(-<.)166.7%12  NB. again, x is extra
>> 11.2
>>
>> I wonder if there is an easier way to do this, which in my recollection
>> seems to be in the wheelhouse of Ian's Tabula or its brethren. I had
>> expected #: to be involved in the calculations, but could not find such.
>>
>>
>> --
>> (B=)
>>
>> --
>> 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
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] (no subject)

2017-10-02 Thread &#x27;Bo Jacoby&#x27; via Programming
f=.[:+/]*[:|:(2#~#)#:[:i.2^#
f 2 5 7

0 7 5 12 2 9 7 14
 g=.[:*/]^[:|:(2#~ #)#:[:i.2^#
 g 2 5 7
1 7 5 35 2 14 10 70
NB. I didn't check if this solution has already been offered. I just coded it.
 

Den 21:40 mandag den 2. oktober 2017 skrev Raul Miller 
:
 

 Perhaps this is closer to what you want?

  F=:1 :', u@> { (~. (u@#"0~ i.@>:)&.> #/.~) y'
  f=: /F

  *f 2 2 5 7
1 7 5 35 2 14 10 70 4 28 20 140
  +f 2 2 5 7
0 7 5 12 2 9 7 14 4 11 9 16

I probably should just merge the two definitions together, but I think
this works?

(Note that I have sort of assumed that the verb argument to f is an
associative verb. If you're doing something where that is not the
case... well... I guess I would need more specification.)

Thanks,

-- 
Raul


On Mon, Oct 2, 2017 at 3:17 PM, Skip Cave  wrote:
> Sorry about the wrong terminology. What i meant was:
>
> Given a vector of random integers (there may be duplicates), what is the
> most concise and or efficient way to
> generate a list of the numbers along with the sum of all combinations of
> the numbers in a single vector? How about the  products of all
> combinations?
>
> Skip Cave
> Cave Consulting LLC
>
> On Mon, Oct 2, 2017 at 1:51 PM, Raul Miller  wrote:
>
>> Prime factors of an integer are not, in the general case, a set. And
>> you really should be careful to avoid specifying a set when what you
>> want is not a set.
>>
>> You might be interested in
>> https://rosettacode.org/wiki/Factors_of_an_integer#J ?
>>
>> That said, refinement is an important part of the specification
>> process, so - since it seems you were looking for something different
>> - maybe it's worth redoing the specification?
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Mon, Oct 2, 2017 at 2:09 PM, Skip Cave  wrote:
>> > My original approach was even more naive than Marc's:
>> >
>> > NB. from    Roger Hui's Combinations essay on the J website:
>> > https://goo.gl/WL4nXn
>> >
>> > c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^)      NB. Roger called this
>> 'comb2'
>> >
>> > NB. I used this definition because I could cut & paste one line, and not
>> > require an editor
>> >
>> >      a =. 2 2 5 5
>> >
>> > ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a
>> >
>> > 100 20 50 4 10 25 2 5
>> >
>> >
>> > I like to sort it:
>> >
>> >      /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a
>> >
>> > 2 4 5 10 20 25 50 100
>> >
>> >
>> > The final goal of this exercise was to find all the divisors of an
>> integer
>> > (not just the prime divisors).
>> >
>> >
>> > So you need to find the prime factors of the integer, for example 100:
>> >
>> >
>> >      ]a =. q:100
>> >
>> > 2 2 5 5
>> >
>> >          /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c
>> 4){a
>> >
>> > 2 4 5 10 20 25 50 100
>> >
>> >
>> > So these are all the divisors of 100.
>> >
>> >
>> > To use Raul's verb, it needs some mods. I can't do the unique until the
>> > end, because prime factors of an integer are often duplicated.
>> >
>> >
>> >      F1=:1 :'u@#~ #:@i.@(2^#)'    NB. Here's Raul's verb minus the
>> initial
>> > unique
>> >
>> > */F1 q:100      NB. we take the product
>> >
>> > 1 5 5 25 2 10 10 50 2 10 10 50 4 20 20 100
>> >
>> > ~.*/F1 q:100    NB. Now we take the unique
>> >
>> > 1 5 25 2 10 50 4 20 100
>> >
>> > /:~~.*/F1 q:100      NB. Sort it to make it pretty
>> >
>> > 1 2 4 5 10 20 25 50 100
>> >
>> >
>> > Didn't really need the 1, but Raul likes the empty combination.
>> >
>> >
>> > Now we put it all in one verb:
>> >
>> >
>> >      F2=. /:~~.*/F1 q:
>> >
>> >      F2 100
>> >
>> > |length error: F2
>> >
>> > | F2 100
>> >
>> >      F2=. /:~~.*/F1 q:]
>> >
>> >      F2 100
>> >
>> > |domain error: F2
>> >
>> > | F2 100
>> >
>> >
>> > So this is above my pay grade. I'll have to stick with my inline code:
>> >
>> >
>> >      /:~~.*/F1 q:110
>> >
>> > 1 2 5 10 11 22 55 110
>> >
>> >      /:~~.*/F1 q:43
>> >
>> > 1 43
>> >
>> >      /:~~.*/F1 q:45
>> >
>> > 1 3 5 9 15 45
>> >
>> >      /:~~.*/F1 q:444
>> >
>> > 1 2 3 4 6 12 37 74 111 148 222 444
>> >
>> >
>> > So I can find all the divisors of an integer.
>> >
>> >
>> > Skip
>> >
>> >
>> >
>> >
>> >
>> >
>> > Skip Cave
>> > Cave Consulting LLC
>> >
>> > On Mon, Oct 2, 2017 at 12:15 PM, Marc Simpson  wrote:
>> >
>> >> More naive than Raul's approach, first pass using the 'stats' lib:
>> >>
>> >>      a=.2 5 7
>> >>      require'stats'
>> >>      combv=: ] {~ (comb #@])
>> >>      3 combv a
>> >> 2 5 7
>> >>      2 combv a
>> >> 2 5
>> >> 2 7
>> >> 5 7
>> >>      1 combv a
>> >> 2
>> >> 5
>> >> 7
>> >>      combos=: (1 + i.@#) <@combv"0 1 ]
>> >>      combos a
>> >> ┌─┬───┬─┐
>> >> │2│2 5│2 5 7│
>> >> │5│2 7│        │
>> >> │7│5 7│        │
>> >> └─┴───┴─┘
>> >>      f=: 1 : ';u/"1 each combos y'
>> >>      +f a
>> >> 2 5 7 7 9 12 14
>> >>      *f a
>> >> 2 5 7 10 14 35 70
>> >>
>> >> /M
>> >>
>> >> On Mon, Oct 2, 2017 at 10:06 AM, Raul Miller 
>> >> wrote:
>> >> > For a first effort, I would go with
>> >> >
>> >> >      F=:1 :'(u@#~

[Jprogramming] load'plot'

2017-10-19 Thread &#x27;Bo Jacoby&#x27; via Programming
 What to do?Thanks. Bo. 
   load 'plot'not found: 
c:/users/admin/downloads/j805_win32/j805/addons/graphics/plot/plot.ijs|file 
name error: script| 0!:0 y[4!:55<'y'
 JVERSIONEngine: j805/j32/windowsRelease-b: 
commercial/2017-04-20T13:26:01Library: 8.05.14Qt IDE: 1.5.4/5.6.2Platform: Win 
32Installer: J805 installInstallPath: 
c:/users/admin/downloads/j805_win32/j805Contact: www.jsoftware.com
--
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] load'plot'

2017-10-19 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank yos. Raul's suggestion did not work for me, but Louis' suggestion:did 
work.

   install'all'
Updating server catalog...
Must run from jconsole
   load'pacman'
   'install' jpkg 'search' jpkg 'plot'
   load'plot'
/Bo. 

Den 22:24 torsdag den 19. oktober 2017 skrev Louis de Forcrand 
:
 

 Otherwise if you just want the plot package I believe the following works:

load ‘pacman’
‘install’ jpkg ‘search’ jpkg ‘plot’

You could make sure that ‘search’ jpkg ‘plot’ brings up only one result.

Louis

> On 19 Oct 2017, at 20:02, Raul Miller  wrote:
> 
> I think I would try:
> 
>  install'all'
>  load'plot'
> 
> Thanks,
> 
> -- 
> Raul
> 
> 
> On Thu, Oct 19, 2017 at 2:01 PM, 'Bo Jacoby' via Programming
>  wrote:
>> What to do?Thanks. Bo.
>>  load 'plot'not found: 
>>c:/users/admin/downloads/j805_win32/j805/addons/graphics/plot/plot.ijs|file 
>>name error: script| 0!:0 y[4!:55<'y'
>> JVERSIONEngine: j805/j32/windowsRelease-b: 
>> commercial/2017-04-20T13:26:01Library: 8.05.14Qt IDE: 1.5.4/5.6.2Platform: 
>> Win 32Installer: J805 installInstallPath: 
>> c:/users/admin/downloads/j805_win32/j805Contact: www.jsoftware.com
>> --
>> 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

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

Re: [Jprogramming] 2D & 3D Point Plots

2017-10-28 Thread &#x27;Bo Jacoby&#x27; via Programming
try
'dot; pensize 5'plot 0j0 2j_3,: _1j2 1j1 _1j_2 3j4

/Bo. 

Den 17:50 lørdag den 28. oktober 2017 skrev Brian Schott 
:
 

 Skip,

The subject of 3d scatterplots was discussed in 2007 without any real
closure. I was able to get the plot suggested by Zach Reiter to work in
jqt, But it does not have all the bells and whistles you require and it
seems to connect the dots. Still it may be a good starting point.

http://www.jsoftware.com/pipermail/programming/2007-March/005625.html

Elsewhere in the thread, Chris Burke gives some overview, too. The search
which got me to the threads follows.

http://www.jsoftware.com/cgi-bin/forumsearch.cgi?all=dot+plot+3d&exa=&one=&exc=&add=⊂=&fid=&tim=0&rng=0&dbgn=1&mbgn=1&ybgn=1998&dend=31&mend=12¥d=2017





-- 
(B=)
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] Natural Language Processing

2017-11-08 Thread &#x27;Bo Jacoby&#x27; via Programming
Justin Terry's voice is ugly on https://www.youtube.com/watch?v=QEtnJdDP1gQ. He 
cannot speak. I doubt that he knows what he is talking about either. Sorry. Bo.
 

Den 18:09 onsdag den 8. november 2017 skrev J. Patrick Harrington 
:
 

 Hi Skip,
    ML (Machine Learning) is a really hot topic and we all need to know
something about it since it will more and more affect our lives.
    I've been sitting in on a course here at U of Maryland called
"Machine Learning for Physicists". I can't follow it at depth, but it
is an introduction to the terminology & state of the art. The lecturer
explains why Python is the language of choice in this area. Basically
because there are open libraries -- here is a youtube video of the
lecture by Justin Terry on why Python:
                  https://www.youtube.com/watch?v=QEtnJdDP1gQ
and there are further lectures you can find. Here is the course site
    https://sites.google.com/view/umdphysicsml/home
A book introducing these concepts/tools I've started to look at is
"Hands-On Machine Learning with Scikit-Learn & TensorFlow" by Geron.
    The really disturbing thing about this field is (a) it is producing
really impressive results, but (b) you can't really analyze what a neural
net is doing.
    I'm not at the point where I can even think about how some of these
techniques might be implimented in J. I'm glad you have introduced the
topic and have given some links to explore.

    Patrick
    ("I, for one, welcome our new ML overlords")


On Wed, 8 Nov 2017, 'Skip Cave' via Programming wrote:
> Natural Language Processing is one of the hottest fields in
> programming today. Recent machine learning and neural network advances have
> made significant improvements in all aspects of NLP. Speech Recognition,
> Speech Synthesis, Knowledge Extraction, and Natural Language Understanding
> have all improved  dramatically, just within the last few years..
>
> Conversational AI devices like Amazon's Echo (Alexa) and Google Home are
> showing up in homes everywhere. Conversational software applications such
> as Google's Assistant (Android), Microsoft's Cortana (Windows), and Apple's
> Siri (iOS) are on every phone and PC.
>
> There are lots of open-source NLP toolkits available to help one build
> these conversational apps. They are written in various languages:
>
>  -
>
>  Natural Language Toolkit (Python) - http://www.nltk.org/  and
>  https://github.com/nltk
>  -
>
>  The Stanford NLP Group (Java) - https://nlp.stanford.edu/software/ and
>  https://stanfordnlp.github.io/CoreNLP/
>  -
>
>  Apache Open NLP - http://opennlp.apache.org/
>  -
>
>  CRAN NLP (in R) https://cran.r-project.org/web/packages/NLP/index.html
>
>
> Two of the newest algorithms used for extracting meaning from text are
> word2vec & doc2vec (doc2vec is also called Paragraph Vectors). Both of
> these algorithms use a technique called "word embeddings" to encode
> individual words. This is particularly interesting because the algorithms
> are able to extract significant information from unstructured text by
> simply analyzing word sequences and the probabilistic relationships between
> neighboring words in any text.
>
> NLP processes are by nature highly parallel array oriented processes,
> dealing with strings and arrays of words. Word 2vec and doc2vec are typical
> in this regard. Both of these algorithms encode words (word2vec) and
> sentences (doc2vec) in a multi-dimensional space (usually 100-200
> dimensions) where machine learning techniques will then cause similar words
> and concepts to gravitate into clusters in the multi-dimensional space.
>
> Here's an overview of how Word2vec extracts meaning from text:
> The amazing power of word vectors | the morning paper
> 
>
> Python seems to be the popular language for coding these algorithms, though
> it is not particularly noted for its array-handling properties.  It would
> seem that array oriented languages such as J would be more suited to
> implementing word2vec and doc2vec.
>
> Here are implementations of both algorithms in Python:
>
>  -
>
>  Word2vec (Python)  https://radimrehurek.com/gensim/models/word2vec.html
>    https://github.com/danielfrg/word2vec
>  -
>
>  Doc2Vec (Paragraph Vectors) (Python)  https://github.com/jhlau/doc2vec
>
>
> How hard would it be to implement these two algorithms in J? I don't know
> Python, so I can't judge the complexity.
>
> Skip
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm

   
--
F

[Jprogramming] geometric mean, and rank

2017-11-17 Thread &#x27;Bo Jacoby&#x27; via Programming
The arithmetic mean is
   E=.+/ % #
For example   E 2 3
2.5
The geometric mean is 
  E&.(2&^.) 2 3
2.44949
or
E&.:(^.) 2 3
2.44949
but (&.) does not work with (^.)
E&.(^.) 2 3
2 3
How come?
Thank! Bo. 

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

Re: [Jprogramming] (no subject)

2017-11-23 Thread &#x27;Bo Jacoby&#x27; via Programming
   +/10^i.50x
11 

Den 9:17 torsdag den 23. november 2017 skrev 'Skip Cave' via Programming 
:
 

 I want to greate an integer with all ones:

  ".10#'1'

11


  datatype ".10#'1'

integer


  ".15#'1'

111

  datatype ".15#'1'

integer


  ".20#'1'

1.1e19


NB. Drat! it seitched to floating.


    datatype ".20#'1'

floating

NB. So I need to use extended precision:

    x:".20#'1'

0656


NB. Uh oh! something is wrong. Not all ones!


    datatype x:".20#'1'

rational


NB. Rational? What happened to extended precision?

NB. So how do I create an integer with say, 50 onres?


    x:".50#'1'

0805019569335803527359330256945152


NB. Nope!



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

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

Re: [Jprogramming] (no subject)

2017-11-23 Thread &#x27;Bo Jacoby&#x27; via Programming
   9%~1-~10^50x

11
without using any array
 

Den 9:33 torsdag den 23. november 2017 skrev 'Skip Cave' via Programming 
:
 

 Thanks Bo.
I also found this:
    (50#10)#.1x
11

Skip Cave


On Thu, Nov 23, 2017 at 2:26 AM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

>    +/10^i.50x
> 11
>
>    Den 9:17 torsdag den 23. november 2017 skrev 'Skip Cave' via
> Programming :
>
>
>  I want to greate an integer with all ones:
>
>  ".10#'1'
>
> 11
>
>
>  datatype ".10#'1'
>
> integer
>
>
>  ".15#'1'
>
> 111
>
>  datatype ".15#'1'
>
> integer
>
>
>  ".20#'1'
>
> 1.1e19
>
>
> NB. Drat! it seitched to floating.
>
>
>    datatype ".20#'1'
>
> floating
>
> NB. So I need to use extended precision:
>
>    x:".20#'1'
>
> 0656
>
>
> NB. Uh oh! something is wrong. Not all ones!
>
>
>    datatype x:".20#'1'
>
> rational
>
>
> NB. Rational? What happened to extended precision?
>
> NB. So how do I create an integer with say, 50 onres?
>
>
>    x:".50#'1'
>
> 0805019569335803527359330256945152
>
>
> NB. Nope!
>
>
>
> Skip Cave
> --
> 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

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

Re: [Jprogramming] Subset Permutations

2017-11-27 Thread &#x27;Bo Jacoby&#x27; via Programming
   sper=:>@(#~(-: ~.)@>)@,@{@($ <@i.)
 10#.1+2 sper 4
12 13 14 21 23 24 31 32 34 41 42 43
 10#.1+3 sper 4
123 124 132 134 142 143 213 214 231 234 241 243 312 314 321 324 341 342 412 413 
421 423 431 432
 

Den 6:22 mandag den 27. november 2017 skrev Linda Alvord 
:
 

 It took me a while, but here is an explicit version of your solution:
sper=:>@(#~(-: ~.)@>)@,@{@($ <@i.)
  
sper2=: 13 :'>((-: ~.)@>,{x$mailto:programming-boun...@forums.jsoftware.com] On Behalf 
Of robert therriault
Sent: Monday, November 20, 2017 3:23 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Subset Permutations

A really quick hack at the problem gave me this

  sper=:>@(#~(-: ~.)@>)@,@{@($ <@i.)
  3 sper 4
0 1 2
0 1 3
0 2 1
0 2 3
0 3 1
0 3 2
1 0 2
1 0 3
1 2 0
1 2 3
1 3 0
1 3 2
2 0 1
2 0 3
2 1 0
2 1 3
2 3 0
2 3 1
3 0 1
3 0 2
3 1 0
3 1 2
3 2 0
3 2 1
  2 sper 4
0 1
0 2
0 3
1 0
1 2
1 3
2 0
2 1
2 3
3 0
3 1
3 2
  1 sper 4
0
1
2
3

Cheers, bob

> On Nov 19, 2017, at 11:49 PM, 'Skip Cave' via Programming 
>  wrote:
> 
> How to find the permutations of y objects taken x at a time?
> 
>    3 sper 4
> 
> 0 1 2
> 
> 0 1 3
> 
> 0 2 1
> 
> 0 2 3
> 
> 0 3 1
> 
> 0 3 2
> 
> 1 0 2
> 
> 1 0 3
> 
> 1 2 0
> 
> 1 2 3
> 
> 1 3 0
> 
> 1 3 2
> 
> 2 0 1
> 
> 2 0 3
> 
> 2 1 0
> 
> 2 1 3
> 
> 2 3 0
> 
> 2 3 1
> 
> 3 0 1
> 
> 3 0 2
> 
> 3 1 0
> 
> 3 1 2
> 
> 3 2 0
> 
> 3 2 1
> 
> 
>    2 sper 4
> 
> 0 1
> 
> 0 2
> 
> 0 3
> 
> 1 0
> 
> 1 2
> 
> 1 3
> 
> 2 0
> 
> 2 1
> 
> 2 3
> 
> 3 0
> 
> 3 1
> 
> 3 2
> 
>    1 sper 4
> 0
> 1
> 2
> 3
> 
> Skip
> --
> 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

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

Re: [Jprogramming] PERT / graph operations

2017-11-29 Thread &#x27;Bo Jacoby&#x27; via Programming
In 1980 I made a program for passing the diagram of activities for a large 
project, computing duration and cost of the project, based on durations and 
costs of the activities. 
In PERT you have a record per node and a record per edge in the graph. I didn't 
do it that way. I still had a record per node but no record describing the 
edges. Rather the numbering of the nodes defined the edges.
This numbering is documented here. ORDINAL FRACTIONS - the algebra of data
  
|  
|   
|   
|   ||

   |

  |
|  
||  
ORDINAL FRACTIONS - the algebra of data
 This paper was submitted to the 10th World Computer Congress, IFIP 1986 
conference, but rejected by the referee  |   |

  |

  |

 
The numbering of activities is such that activities 1 and 2 are in series and 
11 and 12 are in parallel and so on. I used 11-figure ordinal fractions where 
the odd-numbered digit positions indicated series and even-numbered digit 
positions indicated parallel.
Of cause the durations of activities in series must be added together, (+/) and 
durations of activities in parallel must be maxed together (>./).
This is the smarter way to handle activity diagrams. 
Thanks.
Bo  

Den 3:31 onsdag den 29. november 2017 skrev Daniel Lyons 
:
 

 

> On Nov 28, 2017, at 7:11 PM, Henry Rich  wrote:
> 
> You're right about the last bit - you can't start with a transitive closure.  
> I missed that.
> 
> Suppose you turn each dependency into a J sentence, say
> 
> a =: 5
> 
> or
> 
> c =: longerof (a , b)
> 
> or
> 
> f =: a following (e , g)
> 
> or combinations thereof.  There must be no loops in the dependencies, so you 
> could do a topological sort on the tasks, to ensure that each assignment 
> refers only to names that have already defined.  Then just execute the sorted 
> script and see the results.
> 
> You would need the definitions
> 
> longerof =: >./
> following =: +
> 
> and you need a topological sort, which isn't too hard.  I know I wrote one 
> for the Advent of Code problems a couple of years ago.


That's kind of a cool idea. Is it commonly done, generating a block of code in 
a string and evaluating it?

-- 
Daniel Lyons




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

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

Re: [Jprogramming] delete item; ass. lists

2017-12-04 Thread &#x27;Bo Jacoby&#x27; via Programming
Erling Hellenäs is playing with the idea of tying labels to the noun. The noun 
could have a label, labels could be tied to rows and columns. Addressing and 
indexing could then optionally be done 
with those labels.
For your information, using ordinal fractions this is done like this.
00 noun
10 first row
20 second row
01 first column
02 second column
11 array element 
12 array element 
21 array element 
22 array element 
Note that the digit value zero (0) is wild card character rather than index. 
/Bo. 

Den 12:33 mandag den 4. december 2017 skrev Raul Miller 
:
 

 Ok, so https://en.wikipedia.org/wiki/Associative_array rather than
https://en.wikipedia.org/wiki/Association_list?

For this, I think I'd use a pair of lists - one of keys, one of
values. Possibly I'd stick them in a pair of boxes so I could pretend
to be using a purely functional parameter system. But given the
emphasis on mutability here, I think I'd prefer to refer to them by
name. I'll think about this a bit and probably add a note to the
referenced rosettacode entry.

If I were adding a type to J, I'd probably want to borrow K's table
type (probably including deep ties to the assignment operations and
the part where you can transpose them to get a different
representation, though I'm not sure that |: would be the way to
achieve that kind of transpose).

Thanks,

-- 
Raul

On Sun, Dec 3, 2017 at 4:06 PM, Marshall Lochbaum  wrote:
> The associative lists that Andrew is talking about (also called maps or
> dictionaries) are essentially the same as JSON objects (more precisely,
> JSON objects are maps whose keys are strings). There's no need for them
> to be used in a particularly low-level way, although the primitives used
> to manipulate them would have to be different from J's array primitives.
> Examples might be combining two maps but giving preference to one of
> them when they conflict, or inverting a map by swapping keys and values.
>
> Lisp stands for "list processing", and its fundamental datatype is the
> linked list, composed of value-reference pairs. These aren't related to
> associative arrays, at least not any more than they are related to any
> other datatype.
>
> I feel pretty strongly that an associative array type is missing in J,
> but it's understandable given how hard such a type would be to specify
> and implement. That doesn't make it any easier to live without them,
> though.
>
> Marshall
>
> On Sun, Dec 03, 2017 at 01:50:43PM -0500, Raul Miller wrote:
>> <<< means "box three times"
>>
>>    <2
>> ┌─┐
>> │2│
>> └─┘
>>    <<2
>> ┌───┐
>> │┌─┐│
>> ││2││
>> │└─┘│
>> └───┘
>>    <<<2
>> ┌─┐
>> │┌───┐│
>> ││┌─┐││
>> │││2│││
>> ││└─┘││
>> │└───┘│
>> └─┘
>>
>> See also the documentation on the index operation (Henry gave you a
>> reference for that).
>>
>> Also, as I understand it, JSON has only a loose relationship with
>> a-lists. My understanding of them is that they are the fundamental
>> datatype provided by the lisp / scheme / .. family of languages.
>> Basically, you're working with pointer chasing. In J, you can use
>> indices or names as references, if you want to build a workalike - but
>> usually it's just not worth the bother.
>>
>> And that "encode" method is building a name based on an arbitrary
>> string. You should probably think of it as a hash function. But
>> there's a typo - there should be a space after the v in inv. But this
>> suggests also that rosettacode is having bitrot issues with its
>> storage system, and that has all sorts of unpleasant implications.
>> Basically, you are not going to be able to use rosettacode
>> implementations - in the general case - unless you are prepared to
>> debug them (which kind of defeats the purpose of having the site in
>> the first place.) ... wait, no.. when I go to that rosettacode page, I
>> see a space after the 'inv' keyword. Well.. it could still be bitrot,
>> but perhaps at the cloudfront level rather than on the site itself...
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>>
>> On Sun, Dec 3, 2017 at 1:24 PM, Andrew Dabrowski  
>> wrote:
>> > 1. Yes, I should been more specific: I wanted to know the idiomatic way to
>> > delete the nth item of a list, so I think <<< is what I was looking for.
>> >
>> > What is <<< called and where is it documented?
>> >
>> > 2. Not sure what you mean by "Their focus is on micromanaging the sequence
>> > of operations."  A-lists are built into just about every other modern
>> > language because they're so useful at managing information.  Does J not
>> > support JSON for web interoperability?
>> >
>> > One example is using an a-list as a structured object, without having to 
>> > get
>> > into full-blown OO.  I could represent the state of a model using an a-list
>> > and then update the values over time.
>> >
>> > I saw that using classes is one alternative
>> > (https://rosettacode.org/wiki/Associative_array/Creation#J).
>> >
>> > coclass'assocArray'
>> >    encode=:'z',(a.{~;48  65  97(+ i.)&.>10  26  26)  {~62x  #.in

Re: [Jprogramming] contents of a package, permutations

2017-12-08 Thread &#x27;Bo Jacoby&#x27; via Programming
   f=.(#~ ([: */ 1 = +/&(=/~))"1)@(# #: [: i. ^~)
   2 f 4
0 1
0 2
0 3
1 0
1 2
1 3
2 0
2 1
2 3
3 0
3 1
3 2
 

Den 21:30 fredag den 8. december 2017 skrev Jimmy Gauvin 
:
 

 There is a recent thread you might be interested in:

http://jsoftware.com/pipermail/programming/2017-August/048275.html

I like this one from Arie Groeneveld

  vari =: 4 :'y,/@:(],"1 0 -."1)^:(x-1) ,.y'

  2 vari 'abc'
ab
ac
ba
bc
ca
cb

  2 vari i.4
0 1
0 2
0 3
1 0
1 2
1 3
2 0
2 1
2 3
3 0
3 1
3 2
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] i. (2 2 $ 1 2 3 4)

2017-12-13 Thread &#x27;Bo Jacoby&#x27; via Programming
The file:///C:/Users/Admin/Downloads/JWithATwistReferenceManual.pdf describes a 
new language, JWithATwist, but what problem is this language supposed so solve?
Thanks.
Bo. 

Den 17:12 onsdag den 13. december 2017 skrev Erling Hellenäs 
:
 

 Hi all !

It seems some related info did not make it into my blog and it is not 
needed in my manual. My tweets about this are advertently cryptic:

-I found some interesting features of the real #J dyadic rank operator.

-Let's say the rank is zero and the argument is empty, how do you find 
the resulting type and shape?

-Nothing can not be scalar, which can be executed to find the rank, can it?

-If you execute the verb on a scalar default object, what do you do if 
you get an error? Which rank and type will you use?

More clearly:

I have found that J determines the type and shape of the result when 
both arguments of the dyadic array operation helper program are empty by 
executing the verb against default objects of both arguments. If the 
result  is an error, J hides this error. The result then gets another 
rank than it should. The rank is then not consistent with the rank 
obtained when the arguments are not empty.

This means that if you have a theory of how rank works, the theory will 
be falsified by some of the results you get, which means your 
understanding will most probably be fuzzy. You have to test all cases in 
the terminal to verify that it indeed works when one or the other 
argument, or both, are empty.

According to my notes, this is such a case:

    $(i.0) (2 1$ =)"1 0 [i.0
0
    $(i.1) (2 1$ =)"1 0 [i.1
1 2 1

Cheers,

Erling Hellenäs


Den 2017-12-13 kl. 16:24, skrev Erling Hellenäs:
> This blogpost also contains related information. 
> https://erlhelinfotech.wordpress.com/2016/08/17/jwithatwist-scalar-operations/
>  
>
>
> /Erling
>
>
> Den 2017-12-13 kl. 15:46, skrev Erling Hellenäs:
>> It seems you didn't read the parts of my manual I referenced. /Erling
>>
>>
>> Den 2017-12-13 kl. 14:39, skrev Raul Miller:
>>> On Wed, Dec 13, 2017 at 3:46 AM, Erling Hellenäs
>>>  wrote:
 I doubt you can find reasonably accurate descriptions of this 
 functionality
 (these four helper programs) anywhere else.
>>> This suggests to me that you have not read
>>>
>>> http://www.jsoftware.com/help/dictionary/dictb.htm
>>> nor
>>> http://www.jsoftware.com/help/dictionary/dicta.htm
>>>
>>> I am surprised how many people have not read the reference manual -
>>> not just in the J community but among technical people in general.
>>>
>>> I really don't know what to make of this.
>>>
>>
>

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

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

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread &#x27;Bo Jacoby&#x27; via Programming
I am impressed by the J programming language and by the array concept. However, 
boxed arrays and sparse arrays and empty arrays illustrate shortcomings in the 
array concept of J. 
I suggest using ordinal fractions for structuring, storing and handling data. 
Then there is no need for boxing, nor for differentiating between sparse arrays 
and other arrays. However I have not constructed a programming language like J 
to manipulate such data. 
The concept is introduced in the old article behind this link. (Sadly the 
e-mail software tend to disrupt my links. I hope this link survives).
https://www.academia.edu/10031088/ORDINAL_FRACTIONS_-_the_algebra_of_data

Here are some differences between arrays and Ordinal Fractions (OFs):   
   - Arrays have different shapes. OFs have the same shape: (_$9)   

   - J-arrays have zero-origin indexing. OFs have one-origin indexing.   

   - Arrays may have elements. OFs have no elements.   
  

   - Array elements contain data. OFs may contain data.
   - Arrays may contain subarrays. OFs always contain subordinate OFs.
   - An array may have a name. An OF may contain a name. 
   - In J a scalar differs from a shape 1 array.  Not so in OFs.

Here are some differences between nonnegative integers and (OFs):
   
   - Any sequence of digits (0 1 . . . 9) represents a base-ten integer, or a 
base-nine OF.
   - Integers may be padded with zeroes to the left, OFs to the right. 
   - Digit 0 in an integer indicate that a term is omitted. Digit 0 in an OF 
indicate that a condition is omitted. 
   - The integer 0 means "nothing". The OF 0 means "everything".

I think that ordinal fractions is a unified way of structuring data: scalars, 
arrays, trees, databases.alike. 
Thanks
Bo.
 

Den 13:32 onsdag den 20. december 2017 skrev Raul Miller 
:
 

 Actually, J does support arrays of nothing.  That's what i.0 is, after
all. And, if you want a scalar containing an array of nothing, then a:
matches that specification.

And we have an algebra here - though if (as in your previous message)
you do multiplication and call it addition, this becomes very
difficult to talk about.

That said, remember that we can add an arbitrary number of leading 1
dimensions to any array without changing the number of elements in
that array.

Thanks,

-- 
Raul


On Wed, Dec 20, 2017 at 4:03 AM, Erling Hellenäs
 wrote:
> Hi all !
>
> Could we avoid doing these peculiar things in the rank operator if we
> enabled the handling of arrays of nothing?
>
> The verb injected in Rank would then have to give a valid result for an
> array of nothing?
>
> For this to happen J functions have to be defined for handling arrays of
> nothing?
>
> Would it be possible to define an algebra for the handling of arrays of
> nothing?
>
> Could this be the same as enabling missing data?
>
> Cheers,
>
> Erling
>
>
>
> Den 2017-12-20 kl. 09:46, skrev Erling Hellenäs:
>>
>> This is a mathematical concept:
>> https://en.wikipedia.org/wiki/Empty_product /Erling
>>
>>
>> Den 2017-12-20 kl. 09:39, skrev Erling Hellenäs:
>>>
>>> */i.0
>>>
>>> 1
>>>
>>> Here the interpreter automatically adds a 1 to get this peculiar result.
>>>
>>> /Erling
>>>
>>> Den 2017-12-19 kl. 20:01, skrev Raul Miller:

 An empty tank zero array would be inconsistent.

 The number of elements in an array is the product of its dimensions, and
 the multiplicative identity is 1, not 0.

 Thanks,

>>>
>>> --
>>> 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
--
For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] shortening a verbose expression

2018-01-06 Thread &#x27;Bo Jacoby&#x27; via Programming
Tiny simplification:
   vec=:((1 o.{.)*2 1 o.{:),2 o.{.      vec o.1.25 _0.55
0.110616 0.698401 _0.707107
 

Den 23:07 lørdag den 6. januar 2018 skrev Jerry 
:
 

 I am a relative newbie and am trying to teach myself the intricacies by 
addressing a simple problem: some geometric operations on the surface of 
a unit sphere.  The first step is to take latitude and longitude angles 
and create a Cartesian vector pointing from the center of the sphere to 
that point.  I can do that via:

vec =: ((1 o. }:)*(2 o. {:)),((1 o. }:)*(1 o. {:)),(2 o. }:)

this verb yields the desired vector

     [vec o. (1.25,_0.55)

0.110616 0.698401 _0.707107

    +/([vec o. (1.25,_0.55))^2

1

Is there a shorter, less verbose way of writing the verb 'vec'?

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

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

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread &#x27;Bo Jacoby&#x27; via Programming
What does 'best' method mean? Bisection is OK
f=. 3 : '(-2^2^y) + (2^y) +8'
 f 1.818415 1.81842 1.61514e_5 _6.92891e_5


 

Den 16:04 mandag den 29. januar 2018 skrev Raul Miller 
:
 

 Oops, yes, sorry, careless of me.

Thanks,

-- 
Raul


On Mon, Jan 29, 2018 at 4:12 AM, Rob Hodgkinson  wrote:
> Minor correction Raul (- instead of +) ?
> ...  use (8: + (2&^) - (2&^)@(2&*))
>
> So Skip, just to clarify to see this solution put through Newton-Raphson;
>
> 1)  Create the Newton-Raphson adverb as you stated earlier;
>      N=: 1 : '- u % u d. 1’
>
> 2)  Apply for a number of iterations using ^: and give it an initial value of 
> 1  …  fn N (^:iterations) start-value
>    (8: + (2&^) - (2&^)@(2&*))N (^:20) 1
> 1.75372
>
>    9!:11]14  NB. or increase print precision
>    (8: + (2&^) - (2&^)@(2&*))N (^:20) 1
> 1.7537248941553
>
> Hope that clarifies things, as without the function appropriately defined as 
> Raul described, N returns a Domain Error if it can’t work with the function.
>
> Rob
>
>> On 29 Jan 2018, at 7:57 pm, Raul Miller  wrote:
>>
>> d. 1 wants to be able to use the chain rule for 2^2*x, and it seems
>> like the implementation was from an early version of J, and has not
>> kept up with all the more recent changes. So, you should put that
>> changed term into an f@g form.
>>
>> In other words, use (8: + (2&^) + (2&^)@(2&*))
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Mon, Jan 29, 2018 at 1:46 AM, Skip Cave  wrote:
>>> I see what I did wrong.
>>>
>>> The equation is:  8 + (2^x) - 2^2*x = 0
>>>
>>> The  third term is (2^2*x) not (2^2^x)
>>>
>>> That should get close to the answer x=1.75372
>>>
>>> I'm mostly interested in how to formulate the code to implement the Newton
>>> Raphson solution
>>> using
>>>
>>> N=: 1 : '- u % u d. 1'
>>>
>>> In the NR code, where does the equation verb go?
>>> How does it need to be structured? Where does the iteration count limit go?
>>>
>>> Skip
>>>
>>>
>>>
>>>
>>> Skip Cave
>>> Cave Consulting LLC
>
> --
> 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

Re: [Jprogramming] Vector Similarity

2018-02-20 Thread &#x27;Bo Jacoby&#x27; via Programming
ORDINAL FRACTIONS - the algebra of data
  
|  
|   
|   
|   ||

   |

  |
|  
||  
ORDINAL FRACTIONS - the algebra of data
 This paper was submitted to the 10th World Computer Congress, IFIP 1986 
conference, but rejected by the referee  |   |

  |

  |

 
 

Den 22:42 tirsdag den 20. februar 2018 skrev Skip Cave 
:
 

 Very nice! Thanks Raul.

However, there is something wrong about the cosine similarity,
which should always be between 0 & 1

prod=:+/ .*

1 1 1 (prod % %:@*&prod) 0 3 3

1.41421

​Skip

On Tue, Feb 20, 2018 at 2:27 PM, Raul Miller  wrote:

> I don't know about blog entries - I think there are probably some that
> partially cover this topic.
>
> But it shouldn't be hard to implement most of these operations:
>
> Euclidean distance:
>
>    1 0 0 +/&.:*:@:- 0 1 0
> 1.41421
>
> Manhattan distance:
>
>    1 0 0 +/@:|@:- 0 1 0
> 2
>
> Minkowski distances:
>
>    minkowski=: 1 :'m %: [:+/ m ^~ [:| -'
>    1 0 0 (1 minkowski) 0 1 0
> 2
>    1 0 0 (2 minkowski) 0 1 0
> 1.41421
>
> Cosine similarity:
>
>    prod=:+/ .*
>    1 0 0 (prod % %:@*&prod) 0 1 0
> 0
>
> Jacard Similarity:
>
>    union=: ~.@,
>    intersect=: [ ~.@:-. -.
>    1 0 0 (intersect %&# union) 0 1 0
> 1
>
> You'll probably want to use these at rank 1 ("1) if you're operating
> on collections of vectors.
>
> But, I'm a little dubious about the usefulness of Jacard Similarity,
> because of the assumptions it brings to bear (you're basically
> encoding sets as vectors, which means your multidimensional vector
> space is just a way of encoding a single unordered dimension).
>
> Anyways, I hope this helps,
>
> --
> Raul
>
>
>
> On Tue, Feb 20, 2018 at 2:08 PM, Skip Cave 
> wrote:
> > One of the hottest topics in data science today is the representation of
> > data characteristics using large multi-dimensional arrays. Each datum is
> > represented as a data point or multi-element vector in an array that can
> > have hundreds of dimensions. In these arrays, each dimension represents a
> > different attribute of the data.
> >
> > Much useful information can be gleaned by examining the similarity, or
> > distance between vectors in the array. However, there are many different
> > ways to measure the similarity of two or more vectors in a
> multidimensional
> > space.
> >
> > Some common similarity/distance measures:
> >
> > 1. Euclidean distance  >:
> > The length of the line between two data points
> >
> > 2. Manhattan distance :
> Also
> > known as Manhattan length, rectilinear distance, L1 distance or L1 norm,
> > city block distance, Minkowski’s L1 distance, taxi-cab metric, or city
> > block distance.
> >
> > 3. Minkowski distance: 
> a
> > generalized metric form of Euclidean distance and Manhattan distance.
> >
> > 4. Cosine similarity: 
> The
> > cosine of the angle between two vectors. The cosine will be between 0 &1,
> > where 1 is alike, and 0 is not alike.
> >
> > 5
> >  uploads/2015/04/minkowski.png>.
> > Jacard Similarity:  The
> > cardinality of
> > the intersection of sets divided by the cardinality of the union of the
> > sample sets.
> >
> > Each of these metrics is useful in specific data analysis situations.
> >
> > In many cases, one also wants to know the similarity between clusters of
> > points, or a point and a cluster of points. In these cases, the centroid
> of
> > a set of points is also a useful metric to have, which can then be used
> > with the various distance/similarity measurements.
> >
> > Is there any essay or blog covering these common metrics using the J
> > language? I would seem that J is perfectly suited for calculating these
> > metrics, but I haven't been able to find anything much on this topic on
> the
> > J software site. I thought I would ask on this forum, before I go off to
> > see what my rather rudimentary J skills can come up with.
> >
> > Skip
> > --
> > 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

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

Re: [Jprogramming] Vector Similarity

2018-02-21 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you, Skip!
I tried to publish an Ordinal Fraction article in wikipedia, but it was removed 
because original research is not allowed in wikipedia. However somebody copied 
it into this link: StateMaster - Encyclopedia: Ordinal fraction . I think that 
the most obvious use of ordinal fractions is to unify, simplify, and replace: 
arrays, trees, and relational databases. It is scaringly easy. 
  
|  
|   
|   
|   ||

   |

  |
|  
|   |  
StateMaster - Encyclopedia: Ordinal fraction
   |   |

  |

  |

 
 

Den 2:45 onsdag den 21. februar 2018 skrev Skip Cave 
:
 

 ​​Bo,

I read your paper "Ordinal Fractions
<https://drive.google.com/file/d/15-1Z75tkBBgIj7IbNeRy8SpWZc93UuPq/view?usp=sharing>"
paper. In your paper you propose ordinal fractions as a system for
numerically defining data categories and indices, along with an associated
algebra for manipulating the data. As you say in your paper, "the algebraic
properties of ordinal fractions depict closely the logical properties of
natural language". That's intriguing to me, as NLP is the avenue of
research that I am currently pursuing.

Your examples show how you can take a set of human characteristics: boy,
girl; naughty, nice; black hair, blonde; and encode those characteristics
in a numerical index.

Recently, several attempts have again been made to define the meanings of
words numerically. The most notable recent attempts were Miklov's Word2Vec
<https://en.wikipedia.org/wiki/Word2vec> and Pennington's GloVe
<https://nlp.stanford.edu/pubs/glove.pdf>.

Word2Vec uses a technique they call 'one hot' word embeddings. This encodes
each word as a lengthy unique vector containing all zeros except for a
single one representing the meaning of that specific word. The number of
zeros in the vector represents the number of different words
available  They then train shallow, two-layer neural networks
<https://en.wikipedia.org/wiki/Neural_network> to reconstruct linguistic
contexts of words by comparing adjacent words.

GloVe uses a specific weighted least squares model that trains on global
word-word co-occurrence counts and makes efficient use of statistics for
the model.  The gloVe model produces a word vector space with meaningful
substructure, as evidenced by its state-of-the-art performance of 75%
accuracy on the word analogy data set.

Both word2vec and gloVe provide open-source datasets which  provide word
vectors that have been trained on massive text corpora. Each dataset claims
to represent the meaning of each of the words in their dataset by a lengthy
numerical vector.

A third, even more recent word vector database has been created by a
company called Luminoso. They have combined the word2vec and gloVe datasets
into a new set they call Numberbatch <https://goo.gl/XC7A77>, which they
have also open-sourced.

With all these word embedding data sets, you theoretically should be able
to pick a word, and then find other words with similar meanings by simply
finding nearby words, in the Euclidean sense of distance in a
multi-dimensional space. So these datasets are kind of like a numerical
Thesarus. Even more interesting is that parallel vectors in that space have
related meanings: man is to woman, as king is to queen. The vectors between
these two pairs of  words with similar meanings are parallel, and of
similar length.

Skip


Skip Cave
Cave Consulting LLC

On Tue, Feb 20, 2018 at 4:20 PM, 'Bo Jacoby' via Programming <
programm...@jsoftware.com> wrote:

> ORDINAL FRACTIONS - the algebra of data
>
> |
> |
> |
> |  |    |
>
>    |
>
>  |
> |
> |    |
> ORDINAL FRACTIONS - the algebra of data
>  This paper was submitted to the 10th World Computer Congress, IFIP 1986
> conference, but rejected by the referee  |  |
>
>  |
>
>  |
>
>
>
>
>    Den 22:42 tirsdag den 20. februar 2018 skrev Skip Cave <
> s...@caveconsulting.com>:
>
>
>  Very nice! Thanks Raul.
>
> However, there is something wrong about the cosine similarity,
> which should always be between 0 & 1
>
> prod=:+/ .*
>
> 1 1 1 (prod % %:@*&prod) 0 3 3
>
> 1.41421
>
> ​Skip
>
> On Tue, Feb 20, 2018 at 2:27 PM, Raul Miller 
> wrote:
>
> > I don't know about blog entries - I think there are probably some that
> > partially cover this topic.
> >
> > But it shouldn't be hard to implement most of these operations:
> >
> > Euclidean distance:
> >
> >    1 0 0 +/&.:*:@:- 0 1 0
> > 1.41421
> >
> > Manhattan distance:
> >
> >    1 0 0 +/@:|@:- 0 1 0
> > 2
> >
> > Minkowski distances:
> >
> >    minkowski=: 1 :'m %: [:+/ m ^~ [:| -'
> >    1 0 0 (1 minkowski) 0 1 0
> > 2
> >    1 0 0 (2 minkowski) 0 1 0
> > 1.4142

Re: [Jprogramming] Vector Similarity

2018-03-01 Thread &#x27;Bo Jacoby&#x27; via Programming
Thank you Skip! But I do not know how to make a 
<https://www.academia.edu/>.eduAdvanced Search . /Bo.

Den 22:18 onsdag den 28. februar 2018 skrev Skip Cave 
:
 

 No problem. I was able to download it from here:
https://www.academia.edu/10031088/ORDINAL_FRACTIONS_-_the_algebra_of_data

Skip Cave
Cave Consulting LLC

On Wed, Feb 28, 2018 at 3:04 PM, Martin Kreuzer  wrote:

> Skip -
>
> The paper can be downloaded from this link
> https://www.academia.edu/people/search?utf8=%E2%9C%93&q=bo+
> jacoby+ordinal+fractions
> provided you have an account to log into ...
>
> If that's not working out -and Bo agrees- I could send you the short paper
> by PM.
>
> -M
>
> At 2018-02-28 14:25, you wrote:
>
> Bo,
>>
>> <https://www.academia.edu/>.edu
>> Advanced Search found 9,227papers containing “ORDINAL FRACTIONSâ€
>> Search within the full text of 20 million papers
>>
>>
>> Skip Cave
>> Cave Consulting LLC
>>
>> On Tue, Feb 20, 2018 at 4:20 PM, 'Bo Jacoby' via Programming <
>> programm...@jsoftware.com> wrote:
>>
>> > ORDINAL FRACTIONS - the algebra of data
>>
>> > |
>> > |
>> > |
>> > |  |    |
>>
>> >    |
>>
>> >  |
>> > |
>> > |    |
>> > ORDINAL FRACTIONS - the algebra of data
>> >  This paper was submitted to the 10th World Computer Congress, IFIP 1986
>> > conference, but rejected by the referee  |  |
>>
>> >  |
>>
>> >  |
>>
>>
>>
>>
>> >    Den 22:42 tirsdag den 20. februar 2018 skrev Skip Cave <
>> > s...@caveconsulting.com>:
>>
>>
>> >  Very nice! Thanks Raul.
>>
>> > However, there is something wrong about the cosine similarity,
>> > which should always be between 0 & 1
>>
>> > prod=:+/ .*
>>
>> > 1 1 1 (prod % %:@*&prod) 0 3 3
>>
>> > 1.41421
>>
>> > ​Skip
>>
>>
>> > On Tue, Feb 20, 2018 at 2:27 PM, Raul Miller 
>> > wrote:
>>
>> > > I don't know about blog entries - I think there are probably some that
>> > > partially cover this topic.
>> > >
>> > > But it shouldn't be hard to implement most of these operations:
>> > >
>> > > Euclidean distance:
>> > >
>> > >    1 0 0 +/&.:*:@:- 0 1 0
>> > > 1.41421
>> > >
>> > > Manhattan distance:
>> > >
>> > >    1 0 0 +/@:|@:- 0 1 0
>> > > 2
>> > >
>> > > Minkowski distances:
>> > >
>> > >    minkowski=: 1 :'m %: [:+/ m ^~ [:| -'
>> > >    1 0 0 (1 minkowski) 0 1 0
>> > > 2
>> > >    1 0 0 (2 minkowski) 0 1 0
>> > > 1.41421
>> > >
>> > > Cosine similarity:
>> > >
>> > >    prod=:+/ .*
>> > >    1 0 0 (prod % %:@*&prod) 0 1 0
>> > > 0
>> > >
>> > > Jacard Similarity:
>> > >
>> > >    union=: ~.@,
>> > >    intersect=: [ ~.@:-. -.
>> > >    1 0 0 (intersect %&# union) 0 1 0
>> > > 1
>> > >
>> > > You'll probably want to use these at rank 1 ("1) if you're operating
>> > > on collections of vectors.
>> > >
>> > > But, I'm a little dubious about the usefulness of Jacard Similarity,
>> > > because of the assumptions it brings to bear (you're basically
>> > > encoding sets as vectors, which means your multidimensional vector
>> > > space is just a way of encoding a single unordered dimension).
>> > >
>> > > Anyways, I hope this helps,
>> > >
>> > > --
>> > > Raul
>> > >
>> > >
>> > >
>> > > On Tue, Feb 20, 2018 at 2:08 PM, Skip Cave 
>> > > wrote:
>> > > > One of the hottest topics in data science today is the
>> representation
>> > of
>> > > > data characteristics using large multi-dimensional arrays. Each
>> datum
>> > is
>> > > > represented as a data point or multi-element vector in an array that
>> > can
>> > > > have hundreds of dimensions. In these arrays, each dimension
>> > represents a
>> > > > different attribute of the data.
>> > > >
>> > > > Much useful information can be gleaned by examining the similarity,
>&g

  1   2   3   >