here is a typical way to get the bin count

(~. ,: #/.~) 5 10 20 # 100 200 300 
100 200 300 
5  10  20

you can obtain a "stretch factor" with e.

5 10 20 e.~ 5 * i.5 
0 1 1 0 1

then apply the stretch factor with # inv

100 200 300 # inv~ 5 10 20 e.~ 5 * i.5 
0 100 200 0 300 



all together:

(5 * i.5) ({.@:] #inv~ [ e. {:@:]) (~. ,: #/.~) 5 10 20 # 100 200 300 
0 100 200 0 300 




----- Original Message -----
From: Joe Bogner <[email protected]>
To: [email protected]
Cc: 
Sent: Friday, November 14, 2014 6:04 AM
Subject: Re: [Jprogramming] projecting onto a fixed grid

I would probably do this:

(ys,0) {~ xs i. xGrid

0 100 200 0 300


On Thu, Nov 13, 2014 at 11:08 AM, Johann Hibschman <[email protected]>
wrote:

> I'm trying to figure out how best to project some values (think counts
> for particular bins) onto a fixed grid of bins (think each bin in
> order).
>
> For example, this does what I want:
>
>    xGrid=: 0 5 10 15 20
>    xs=: 5 10 20
>    ys=: 100 200 300
>    ys (xGrid i. xs)}0*xGrid
> 0 100 200 0 300
>
> It seems a little cumbersome, though, so I was wondering if there's a
> better way.
>
> Thanks,
> Johann
> ----------------------------------------------------------------------
> 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