More particularly - re - Bo Jacoby's original statement on 21/8/20. Probably not
relevant if you haven't followed this branch of the thread.

On the code-smelliness topic - no anosmia here! - I've been nurdling away at your (Bo's) functions for generalisation of summary stats, even though not yet
understanding what mathematical problem you're solving.

So far I've got:   (using fixed font...)

NB.   stomb to replace s @ tomb
stomb =: (% #) * (+/@:(^/) >:@i.)~

NB.   Ma to replace m

NB. managing to treat i. as a common element,

NB. albeit needing to modify it for some steps

Ma    =: |:@(((_1 ^ [) * (0 - [) |.!.0"0 1 (,"0 1~ >:)~) }:)~ i.@#

cf

   m f.  NB. original
|:@(|: |.!.0"0 1~ -@i.@#)@((* (_1 ^ i.@#))"1@(>:@i.@# , }:)@|:@($~ (2 # #)))

   [data =. #~ i.5
1 2 2 3 3 3 4 4 4 4
   3 stomb data
9 30 106.2
   3 s @ tomb data
9 30 106.2

   3 Ma @ stomb data
 1  0 0
 9 _2 0
30 _9 3

   3 m @ s @ tomb data
 1  0 0
 9 _2 0
30 _9 3
But - I don't like losing the last element of s - we're just wasting that calculation.


As for the maths - you've got numbers ni associated with indices i e. i.N
Let Sk = sum over i of ni.i^k for k e. i. m + 1
Then ∆Sk = m Sk % S[k-1] for k e. 1 + i.m   ( ∆ is Delta if the formatting fails!)


matrix M   is [ 1   0   0    0  ...]

              [∆S1 -2   0    0  ...]

              [∆S2 -∆S1 3    0  ...]

              [∆S3 -∆S2 ∆S1 -4  ...]

                 ............

              [.....      ..... ...]


You then solve for vector b in

    ∆S = M matprod b

so we have

∆S1 = b1
∆S2 = b1 ∆S1 - 2 b2
∆S3 = b1 ∆S2 - b2 ∆S1 + 3 b3
....


You then append 1 to b,  presumably defining a coefficient, b0 = 1 ,

and then find - and negate - the roots of the polynomial

   b0 x^m + b1 x^(m-1) + ... + bm = 0   (I think)


Why?  I don't see a direct relation to Newton interpolation (say),  though there

are some similarities.  Can you provide a reference for your generalised statistics?


Thanks,

Mike



On 23/08/2020 15:58, 'Bo Jacoby' via Programming wrote:
  Raul wrote: "Generalized how?"
The special case n=1 of n&(summary@tomb) is the mean value (+/%#).So the general 
case n&(summary@tomb) is a generalized mean value.
Correctness:

    1 summary@tomb a=. (i.11) ,5#20


9.6875

    (+/%#) a
9.6875

    1 summary@tomb 3 summary@tomb a9.6875


    ((+/%#) 3 summary@tomb a) = (+/%#) a

1



    3 summary@tomb a1.92566 7.43347 19.7034

    (+/%#)1.92566 7.43347 19.70349.68751

    1 summary@tomb 1.92566 7.43347 19.7034
9.68751

Thanks!
Bo




     Den søndag den 23. august 2020 10.01.24 CEST skrev Raul Miller 
<[email protected]>:
For example, consider this crude mechanism:

partmean=:4 :0
   m=. (+/%#) y
   b=. <.(x%n)*i.#y
   w=. b (+/%#)/. /:~ y
   x * m * w%+/w
)

   3 partmean 0 1 2 3 4 5 6 7 8 9 10 20 20 20 20 20
2.38217 7.62295 19.0574

Correct? Incorrect? How would I know?

Note that the calculation for b could be replaced, for example:

arbmean=:4 :0
   m=. (+/%#) y
   b=. ?. (#y) # x
   w=. b (+/%#)/.  y
   x * m * w%+/w
)

   3 arbmean 0 1 2 3 4 5 6 7 8 9 10 20 20 20 20 20
4.77812 13.4155 10.8689
   (+/%#)3 arbmean 0 1 2 3 4 5 6 7 8 9 10 20 20 20 20 20
9.6875

Thanks,


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to