Re: [Jprogramming] Interquartile range

2021-02-21 Thread Brian Schott
The manual method I learned is captured in the following formula. load'stats/base' midpt -:@<:@# median -:@(+/)@((<. , >.)@midpt { /:~) iqr=:((median@{.~-@>.@midpt)-(median@{.~>.@midpt))@/:~ -- (B=) -- For informat

Re: [Jprogramming] Interquartile range

2021-02-21 Thread 'Bo Jacoby' via Programming
For summarizing a data set use En=: 4 : 0 NB. tombola-resume y=.x*(+/%#)(,y)^/1+i.x e=.1 for_i. 1+i.x do.    e=.e,~i%~+/(_1^i.i)*e*i{.y end. _1&x:|.->{:p. e ) The function 1&En is the mean value. 2&En is the mean value plus or minus the standard deviation. 3&En is 3 numbers summarizing the da

Re: [Jprogramming] Interquartile range

2021-02-21 Thread Raul Miller
It's perhaps worth noting that these do not always yield the same result: q2 5 7 11 13 6 q3 5 7 11 13 4 FYI, -- Raul On Sun, Feb 21, 2021 at 6:10 PM xash wrote: > > Without I.: > q2=: (1r4 3r4 <.@* #) -/@:{ \:~ > > And a fun one: > q3=: \:~ -&({~ # <.@% 4:) /:~ > ---

Re: [Jprogramming] Contrintuitive argument order in Fold right verb

2021-02-21 Thread Hauke Rehr
is it? why would J make an exception here? actually, I’ve been using at least %~ more frequently than % I understand that it may be too bad (late?) changing it now that the J community got used to even J adopting this convention. But it wouldn’t/shouldn’t have been of concern when crafting the lang

Re: [Jprogramming] Interquartile range

2021-02-21 Thread xash
Without I.: q2=: (1r4 3r4 <.@* #) -/@:{ \:~ And a fun one: q3=: \:~ -&({~ # <.@% 4:) /:~ -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Contrintuitive argument order in Fold right verb

2021-02-21 Thread Henry Rich
The principle of 'control' v 'data' is one I inferred from the language.  Unfortunately there are exceptions: (x - y), (x % y), and (x ^ y) should be defined the other way, but the pull of convention is just too strong.  And (x e. y), where the exception came by way of Ken's own work. Henry R

Re: [Jprogramming] Interquartile range

2021-02-21 Thread Hauke Rehr
Directly derived from your version: q=: 3 : '(-/@:{~ 3r4 1r4 I.~ #\ % #) /:~y' Didn’t test it, though. Am 21.02.21 um 22:19 schrieb Emir U: > q=: 3 : '-/(((1+ i. #y) % #y) I. 0.75 0.25) {/:~y' -- -- mail written using NEO neo-layout.org -

Re: [Jprogramming] Contrintuitive argument order in Fold right verb

2021-02-21 Thread Hauke Rehr
Well explained. I’ve seen this explanation a couple of times here, but not as much in the documentation (or did I always ignore it?) So I think that’s something beginners shouldn’t be taught much later than the rtl processing. It does make you wonder less about what goes where with many primitives.

[Jprogramming] Interquartile range

2021-02-21 Thread Emir U
I couldn't find this in the archive so here is an attempt at a fairly simple interquartile range function for those who might be looking for it. iqr=: 3 : 0 q=: 3 : '-/(((1+ i. #y) % #y) I. 0.75 0.25) {/:~y' q "1 |: y ) Pretty certain it can be written much more concisely: just not by me righ

Re: [Jprogramming] Contrintuitive argument order in Fold right verb

2021-02-21 Thread Henry Rich
Your argument is unconvincing to me. J generally processes right to left: agreed. J has a principle for deciding which argument of a verb should be on the left: the more 'control-like' argument.  The right argument is more 'data-like'.  You apply the control argument to the data. Thus, (x |

Re: [Jprogramming] Contrintuitive argument order in Fold right verb

2021-02-21 Thread Raul Miller
I have a question about your proposal: 7 ] F:: see_arg 1 2 3 4 4 7 3 11 2 14 1 16 11 14 16 17 The right to left folds pass arguments in a right to left fashion. But why should this be the case for a left to right fold? (I am trying to understand why a left to right fold should be intuitively

[Jprogramming] Contrintuitive argument order in Fold right verb

2021-02-21 Thread 'Sergey' via Programming
Hi! I am glad that in version 9.02 verbs are now executed from right to left, which corresponds to the logic of J. However, in my opinion, the order of passing arguments to the right verb (see_arg in my example) also needs to be changed for the logic of J. see_arg =: dyad : 0 NB. See argume

Re: [Jprogramming] Indeterminate as Constant Function?

2021-02-21 Thread Thomas Bulka
On Sun, 21 Feb 2021 07:28:44 -0600, Julian Fondren wrote: > There's " https://code.jsoftware.com/wiki/Vocabulary/quotem > Common use #2, to make a constant verb out of a noun. > > (_."_)`2:`3:@.] i:2 > 2 3 _. 2 3 Hi Julian, thanks for the hint! This does exactly what I was looking for. R

[Jprogramming] assert. blunder to be fixed in next beta

2021-02-21 Thread Henry Rich
A blunder of mine some releases ago caused the sentence following assert. to be executed even if 0=9!:34'' . That will be fixed in the next beta.  The entire sentence, not just the result, should be ignored. Henry Rich -- This email has been checked for viruses by AVG. https://www.avg.com ---

Re: [Jprogramming] almost real numbers

2021-02-21 Thread Raul Miller
33j15":1j1 1.000 ":1j1 1j1 It looks like that's an issue with the dyadic form of ": (Using anything larger than j15 for the left argument of ": is rarely wise, unless you're working with exact or rational numeric types.) Thanks, -- Raul On Sun, Feb 21, 2021 a

Re: [Jprogramming] almost real numbers

2021-02-21 Thread Don Guinn
A different issue - ": ignores the imaginary part of a number. 33j30":1j1 1.00 On Sun, Feb 21, 2021 at 3:55 AM Raul Miller wrote: > Ok, let's walk through this. > > First, let's extract the J's binary representation of pi: >' '-.~":(64#2)#:256x#.|.a.i.2(3!:5) o.

Re: [Jprogramming] Squared Euclidean distance matrix calculation

2021-02-21 Thread Emir U
Here is small tweak that seems to make a big difference to both the memory consumed and performance: From this: ed=: 4 : 0 row=. 4 : '+/ *: (x - (|: y))' > (row & y) each < "1 x ) to this: ed=: 4 : 0 NB. Euclidean distance row=. +/ @: *: @: (- & (|: y)) > row each < "1 x ) The row func

Re: [Jprogramming] Indeterminate as Constant Function?

2021-02-21 Thread Julian Fondren
There's " https://code.jsoftware.com/wiki/Vocabulary/quotem Common use #2, to make a constant verb out of a noun. (_."_)`2:`3:@.] i:2 2 3 _. 2 3 On 2021-02-21 06:28, Thomas Bulka wrote: Hello everyone, here's what I want to do: I want to use @. on a gerund like this: interesting_verb =: f

[Jprogramming] Indeterminate as Constant Function?

2021-02-21 Thread Thomas Bulka
Hello everyone, here's what I want to do: I want to use @. on a gerund like this: interesting_verb =: f`g`2:`3:@.h h, obviously, is a verb which generates an integer between 0 and 3. However - I'd like to have a case in which _. is returned on some inputs by my verb. While it is possible to ha

Re: [Jprogramming] Squared Euclidean distance matrix calculation

2021-02-21 Thread Emir U
Hey xash, your versions looks great. Very nice and concise and performant too but it doesn't seem to work if there's only 1 record on the left hand side. Emir -- For information about J forums see http://www.jsoftware.com/forums.h

Re: [Jprogramming] almost real numbers

2021-02-21 Thread Raul Miller
Ok, let's walk through this. First, let's extract the J's binary representation of pi: ' '-.~":(64#2)#:256x#.|.a.i.2(3!:5) o.1 01001001001110110101010001000110110100011000 To interpret this, let's refer to the wikipedia page on this numeric format: https://en.wikipedia.org/