R, 6257 bytes
function(lv,`!`=sum,N=!1^v)c(p<A<-Reduce(function(x,y)(x+y)!v/2,l)N,a<P<-mean!v/2^c(lN:1,N),pP-aA)
Pretty straightforward implementationA clever collaboration with digEmAll and RobinRyder; uses the observation by Grimmy and Kevin's explanation from the comments, which I replicate below:
For anyone else wondering why the example
[a,b,c,d] -> [a,b,c,c,d,d,d,d]doesn't match the explanation of the code, it actually transforms[a,b,c,d]to[a,b,b,c,c,c,c,d,d,d,d,d,d,d,d,a](so two of each value in comparison to the example). The example confused me for a moment. But nice answer, +1 from me! I also like that it has all these different types of the letter 'A' in the code:āÅÅAÂÆa. xD
This uses R's recycling rules to use two copies of l[1]/2^N in the sumby just sticking an extra N at the end of the decay rate.
R, 5162 bytes
function(l,L=sum(l|1))sumc(l*2^p<-Reduce(cfunction(1x,1:y)(L-1x+y)/2,l),a<-Lmean(l),p-l/La)
This approach is perhaps more amenable to an improvement that I have overlooked, but only returns the difference progressive - arithmeticStraightforward implementation.
R, 62 bytes
function(l)c(p<-Reduce(function(x,y)(x+y)/2,l),a<-mean(l),p-a)
Pretty straightforward implementation.
R, 51 bytes
function(l,L=sum(l|1))sum(l*2^(c(1,1:(L-1))-L)-l/L)
This approach is perhaps more amenable to an improvement that I have overlooked, but only returns the difference progressive - arithmetic.
R, 57 bytes
function(v,`!`=sum,N=!1^v)c(A<-!v/N,P<-!v/2^c(N:1,N),P-A)
A clever collaboration with digEmAll and RobinRyder; uses the observation by Grimmy and Kevin's explanation from the comments, which I replicate below:
For anyone else wondering why the example
[a,b,c,d] -> [a,b,c,c,d,d,d,d]doesn't match the explanation of the code, it actually transforms[a,b,c,d]to[a,b,b,c,c,c,c,d,d,d,d,d,d,d,d,a](so two of each value in comparison to the example). The example confused me for a moment. But nice answer, +1 from me! I also like that it has all these different types of the letter 'A' in the code:āÅÅAÂÆa. xD
This uses R's recycling rules to use two copies of l[1]/2^N in the sumby just sticking an extra N at the end of the decay rate.
R, 62 bytes
function(l)c(p<-Reduce(function(x,y)(x+y)/2,l),a<-mean(l),p-a)
Straightforward implementation.
R, 4962 bytes
function(l)c(p<-Reduce(function(x,y)(x+y)/2,l),a<-mean(l),p-a)
Pretty straightforward implementation. Reduce(mean,l)-mean(l) would be nice, but mean is not a binary function. Alas.
R, 51 bytes
function(l,L=sum(l|1))sum(l*2^(c(1,1:(L-1))-L)-l/L)
This approach is perhaps more amenable to an improvement that I have overlooked, but only returns the difference progressive - arithmetic.
R, 49 bytes
function(l)Reduce(function(x,y)(x+y)/2,l)-mean(l)
Pretty straightforward implementation. Reduce(mean,l)-mean(l) would be nice, but mean is not a binary function. Alas.
R, 51 bytes
function(l,L=sum(l|1))sum(l*2^(c(1,1:(L-1))-L)-l/L)
This approach is perhaps more amenable to an improvement that I have overlooked.
R, 62 bytes
function(l)c(p<-Reduce(function(x,y)(x+y)/2,l),a<-mean(l),p-a)
Pretty straightforward implementation.
R, 51 bytes
function(l,L=sum(l|1))sum(l*2^(c(1,1:(L-1))-L)-l/L)
This approach is perhaps more amenable to an improvement that I have overlooked, but only returns the difference progressive - arithmetic.
R, 49 bytes
function(l)Reduce(function(x,y)(x+y)/2,l)-mean(l)
Pretty straightforward implementation. Reduce(mean,l)-mean(l) would be nice, but mean is not a binary function. Alas.
R, 51 bytes
function(l,L=sum(l|1))sum(l*2^(c(1,1:(L-1))-L)-l/L)
This approach is perhaps more amenable to an improvement that I have overlooked.