Re: [Jprogramming] k-mediods PAM algo, help with canonical form (xash)

2021-02-15 Thread 'Michael Day' via Programming
Have you decided whether your code does implement the PAM algorithm? xash suggested it might be doing the Voronoi method. Thanks, Mike On 15/02/2021 18:16, Emir U wrote: Hey again xash, I've improved the algo some following your example (especially the use of ./). It has reduced the algo (at

Re: [Jprogramming] Strange result when calculating tringular number

2021-02-15 Thread Henry Rich
Well, it's fixed for the next maintenance release of 9.02 as well, but I don't know when that will be. Henry Rich On 2/15/2021 1:31 PM, 'Michael Day' via Programming wrote: "Fixed for the next beta" suggests you might have overlooked that this problem seems to occur in J9.02 as well. Apologie

Re: [Jprogramming] Strange result when calculating tringular number

2021-02-15 Thread 'Michael Day' via Programming
"Fixed for the next beta" suggests you might have overlooked that this problem seems to occur in J9.02 as well. Apologies if I'm wrong. Cheers, Mike On 15/02/2021 17:16, Henry Rich wrote: It comes down to this:     <. 17575011601890. 0  NB. bug! 17575011601891 0     <. 17575011601890. 175750

Re: [Jprogramming] k-mediods PAM algo, help with canonical form (xash)

2021-02-15 Thread Emir U
Hey again xash, I've improved the algo some following your example (especially the use of ./). It has reduced the algo (at least with random initialisation) to 3 lines ... kM_step=: 4 : 0 vec=. (i. <./) each ;/ x {"1 y argm=. 4 : '{ & x (i. <./) (+/ (<( Subject: Re: k-mediods PAM algo, help wi

Re: [Jprogramming] Strange result when calculating tringular number

2021-02-15 Thread Henry Rich
It comes down to this:     <. 17575011601890. 0  NB. bug! 17575011601891 0     <. 17575011601890. 17575011601890 When I rewrote >. to allow inplace operation, I forgot that comparison tolerance causes trouble when the numbers get big. Singletons follow a different path. Fixed for next beta. 

Re: [Jprogramming] k-mediods PAM algo, help with canonical form (xash)

2021-02-15 Thread xash
kM2 takes in `data`, not the `edist data`. Otherwise, it should work. Though after I realized what this all does, taking in the distance matrix makes more sense. Thus: kM2_step=: 4 : 0 groups=. (i. <./)@:{"1 sub=. {"1 {&x best=. [ {~ [:(i. <./) [:+/"1 sub (y groups x) best/. (i. # x) ) kM2=: ] kM2

Re: [Jprogramming] Strange result when calculating triangular number

2021-02-15 Thread 'Michael Day' via Programming
Sorry,  slightly careless in drafting - I'll correct the errors inline. Please discard my earlier post. On 15/02/2021 13:16, 'Michael Day' via Programming wrote: Yes, it does seem to misbehave. I looked at what happens with @ rather than @:    t0=: <.@ -:@ (* >:)    t1 =: <.@:-:@:(* >:)    (t0

Re: [Jprogramming] Strange result when calculating triangular number

2021-02-15 Thread 'Michael Day' via Programming
Yes,  it does seem to misbehave. I looked at what happens with @ rather than @:    t0=: <.@ -:@ (* >:)    t =: <.@:-:@:(* >:)    (t0,:t1) 5928745 5928745  NB. compare @ with @: 17575011601885 17575011601885 17575011601886 17575011601886 I thought [: might fix it - but no:    tbr0=: [: <. [: -:

Re: [Jprogramming] k-mediods PAM algo, help with canonical form (xash)

2021-02-15 Thread Emir U
Thanks for your comments xash. You're right about average not mattering. Did your kM2_step and kM functions run correctly for you? It doesn't look like it runs to me so far as I can see the group function seems to assume the data to be in the wrong shape for it to work. Can you confirm?

Re: [Jprogramming] k-mediods PAM algo, help with canonical form (Clifford Reiter)

2021-02-15 Thread Raul Miller
If you have f=: 4 : '*: x (-"1) y' And you want an explicit ed, defined in terms of f, which is equivalent to ed=:+/&.:*:@:-"1 Then I would use: ed=: 4 : '%: +/ x f y'"1 Note that "1 needs to be outside the explicit definition for ed/~ to recognize that ed consumes rank 1 items. I hope

Re: [Jprogramming] k-mediods PAM algo, help with canonical form (Clifford Reiter)

2021-02-15 Thread Clifford Reiter
Emir, Maybe something like this ed2=:4 : '+/ *: x - y' ed2m=: ed2"1 _"_ 1~ ed2m 1 2 ,:4 6 0 25 25 0 Note table is just the verb with some rank. You can say something like apply ed2 for all vectors on the left and all vectors on the right with something two ranks like the above. Best, Cliff

[Jprogramming] Strange result when calculating tringular number

2021-02-15 Thread Stefan Baumann
Dear all, I had an issue when calculating the triangular number with the formula <.@:-:@:(* >:) in list context. Starting from 5928745 the outcome in list context is larger than the correct value (additionally calculated with the binomial coefficient in the first box): t=: <.@:-:@:(* >:) ((2