This looks like a version of a classic frequency table. I'll have to look
through old stuff to see what I thought was the best way to do it in the
past.

#/. B=:11 23  11 11 24 11 21 23
1 1 1 1 1 1 1 1
   (~. ,. #/.~) B
11 4
23 2
24 1
21 1

Linda

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of 'Pascal
Jasmin' via Programming
Sent: Monday, March 9, 2015 2:08 AM
To: [email protected]
Subject: Re: [Jprogramming] distributing nub to appropriate positions

is this what you want?

  #/.~ 1,(98$2),3
1 98 1

  (~. ,. #/.~) 1,(98$2),3
1  1
2 98
3  1 




----- Original Message -----
From: Joe Bogner <[email protected]>
To: [email protected]
Cc: 
Sent: Monday, March 9, 2015 12:41 AM
Subject: Re: [Jprogramming] distributing nub to appropriate positions

You are right. It won't be that easy since they are not adjacent. They are
spread throughout in no pattern. That's the downside of using simple test
data. I am glad you spotted it.

I could have each row search for its family total in the table of family
totals. I was concerned it would be slow and was hopeful there was a more
efficient way. I should probably test it before jumping to that conclusion
On Mar 9, 2015 12:25 AM, "Raul Miller" <[email protected]> wrote:

> That'll work if your families are all adjacent.
>
> If they can be shuffled you'll need to do a bit more work.
>
> (But if they are not shuffled, why bother?)
>
> Thanks,
>
> --
> Raul
>
> On Mon, Mar 9, 2015 at 12:22 AM, Joe Bogner <[email protected]> wrote:
> > This seems like it may be a viable solution:
> >
> > (1-~ +/\ (~:families)) { famTotal
> >
> > On Mon, Mar 9, 2015 at 12:15 AM, Joe Bogner <[email protected]> wrote:
> >
> >> I am doing a +//. on a very large array that I need redistribute 
> >> the results back to the original positions.
> >>
> >> The dictionary has a solution that works well on small arrays[1], 
> >> but
> does
> >> not work on my large array since it's using = to self classify
> >>
> >> Example:
> >>
> >> NB. create 3 fake families across 100 rows
> >> families=: 1,(98$2),3
> >> val=: 100 $1
> >>
> >> NB. sum by family
> >> ] famTotal =: families +//. val
> >> 1 98 1
> >>
> >> NB. desired output, result distributed to each row ] desired =: 
> >> famTotal ((+/ .*)=) families
> >> 1 98 98 .... 1
> >>
> >>
> >> NB. confirms desired matches family total
> >>    (~. ( i.~ families)) { desired
> >> 4 3 3
> >>
> >> For my very large array:
> >>
> >> families=.55e6 $ (i.100000)
> >> val =: 55e6 $ 1
> >> famTotal =: families +//. val
> >>
> >> desired =: famTotal ((+/ .*)=) families
> >> |out of memory
> >>
> >>
> >> The reason why is because = families results in a huge array.
> >>
> >> How can I accomplish the same goal efficiently?
> >>
> >>
> >>
> >> 1 - http://www.jsoftware.com/help/dictionary/d221.htm
> >> 2 - http://www.jsoftware.com/jwiki/Vocabulary/eq
> >>
> > --------------------------------------------------------------------
> > -- 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

Reply via email to