Actually it is the only correct answer.

b=. i.4 5 
x=. 0 1 1 1 0, 1 1 1 1 1, 0 0 0 0 0,: 1 1 1 1 0

(+/"1 b*x) % +/"1 b
0.6 1 0 0.77647059
   

R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming- 
> [email protected]] Namens Roger Hui
> Verzonden: woensdag 2 december 2009 18:07
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] averages of non-zero elements of matrices
> 
> And what is the problem?
> 
> I consider 0 to be the correct answer for the average
> if the mask is all 0.
> 
> 
> 
> ----- Original Message -----
> From: Brian Schott <[email protected]>
> Date: Wednesday, December 2, 2009 8:53
> Subject: Re: [Jprogramming] averages of non-zero elements of matrices
> To: Programming forum <[email protected]>
> 
> > Roger,
> >
> > Your solutions do not work well with the third row of all zeros.
> ----------------------------------------------------------------------
> 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