Discuss Scratch

reallysoftuser
Scratcher
1000+ posts

List Statistics

This would use the numbers in a List to get the average, sum, or other statistics.
[mean v] of [my list v] :: operators
[median v] of [my list v] :: operators
[min v] of [my list v] :: operators
[max v] of [my list v] :: operators
[sum v] of [my list v] :: operators
It wouldn't count list entries that have alphabetical letters or symbols.

Last edited by reallysoftuser (April 20, 2022 22:38:49)

TheAnimalKingdom42
Scratcher
1000+ posts

List Statistics

Even though all of those have a workaround, this would be very useful because it is much less complicated. However, does it have to be an extension? Could these just be additional list blocks?

jackson49
Scratcher
1000+ posts

List Statistics

Good idea, but I think it should be a list block, not an operator

Be moist

PC LOAD LETTER

;
Geotale
Scratcher
100+ posts

List Statistics

Though I don't support this, I'll add that Scratch's number conversion would already handle the case where non-numbers are included

Anyways, as for why I don't support this – Every single thing in here is incredibly simple to implement otherwise. The sum of a list? It's not difficult to add up everything in a list – Adding up everything in a list and dividing it by the list length isn't either.
The only one that isn't trivial to implement is median, but when is median actually used?
RL1123
Scratcher
1000+ posts

List Statistics

Sounds cool, but all of these have a somewhat simple workaround:

[sum v] of [my list v] :: operators
[mean v] of [my list v] :: operators

set [index v] to [1]
set [sum v] to [0]
repeat (length of [my list v] :: list)
change [sum v] by (item (index) of [list v] :: list)
change [index v] by (1)
end
set [mean v] to ((sum) / (length of [my list v] :: list))
Sum and mean are very similar, so the workaround can be combined.


[min v] of [my list v] :: operators

set [index v] to [1]
set [min v] to (item (1 v) of [my list v] :: list)
repeat (length of [my list v] :: list)
if <(item (i) of [my list v] :: list) < (min)> then
set [min v] to (item (index) of [ mylist v] :: list)

end
change [index v] by (1)
end
[max v] of [my list v] :: operators

set [index v] to [1]
set [max v] to (item (1 v) of [my list v] :: list)
repeat (length of [my list v] :: list)
if <(item (i) of [my list v] :: list) > (max)> then
set [max v] to (item (index) of [ mylist v] :: list)

end
change [index v] by (1)
end
Min and max are also close to the same exact script.

This median's a bit more difficult:
[median v] of [my list v] :: operators
delete (all v) of [sorted v]
set [index1 v] to [1]
repeat (length of [my list v] :: list)
set [item2 v] to [1]
repeat until <<(item (index1) of [my list v] :: list) < (item (index2) of [sorted v] :: list)> or <(item2) > (length of [sorted v] :: list)>>
change [item2 v] by (1)
end
insert (item (item1) of [my list v] :: list) at (item2) of [sorted v]
change [item1 v] by (1)
end
This chunk of code sorts or puts the list in ascending order so that we can find the number(s) in the middle. I'm aware that there are faster ways to get the median than sorting and there are much faster sorting algorithms, but I'm lazy. Now to get the median from the sorted list:
if <((length of [sorted v] :: list) mod (2)) = [1]> then // If the list has an odd number of elements, get the number from the middle of the list.
set [median v] to (item ([floor v] of ((length of [sorted v] :: list) / (2))) of [sorted v] :: list)


else // we average the two center elements
set [median v] to (((item ([floor v] of ((length of [sorted v] :: list) / (2))) of [sorted v] :: list) + (item ([ceiling v] of ((length of [sorted v] :: list) / (2))) of [sorted v] :: list)) / (2))
end

The main problem I see with these blocks isn't the fact that they're too easy or hard to create, it's that they're hardly ever used. Projects hardly ever use mean and median on lists unless it's some niche project, which is few and far between. For now, I think it would be better if people would create their own code instead of the developers making built-ins to do it for them. Or they can borrow code from other projects, there are many excellent projects out there that have working code on mean, median, sum, min, and max.



through tough thorough thought, though














Signature #11
doodleblues
Scratcher
100+ posts

List Statistics

serious support
Workarounds for theres are extremely inefficient and complicated (i wouldnt even bother trying to use rrl1123's workaround haha Way too complicated) and have these blocks will be a lot easier !!!
If somebody were to apply them to an alphabetical list what would happen ?


k0d3rrr
Scratcher
1000+ posts

List Statistics

What if someone doesn't want to do these specifically for lists? What if they just want to do maths for other things and not lists only?
Also, is this a duplicate? Just wondering: https://scratch.mit.edu/discuss/topic/307629/
Even though it does suggest more features, it also suggests the same things that this suggestion does. (Both suggestions suggest mean, median, and sum. Probably also min and max.)

Last edited by k0d3rrr (April 21, 2022 05:15:35)



Animated button created by me


Despite what my About section says, I have been using Scratch before 2019. 2019 was the year that I first joined Scratch.
mbrick2
Scratcher
1000+ posts

List Statistics

k0d3rrr wrote:

Also, is this a duplicate? Just wondering: https://scratch.mit.edu/discuss/topic/307629/
Without a doubt.
Its suggesting for Mean, Median, Mode, Range, Sum, Product, Biggest, Smallest, Biggest, Least Lettered, Most Lettered. Upper Quartile, Lower Quartile, Interquartile Range and this is Mean, Sum, Median, Min (smallest) and Max (biggest) so that post is just a bigger version if this one.








My Forums
ATs
Collabaration
My collabs
AIPoint
AspectOS
CoreOS
OddyseyOS
Cops and Robbers
#BringBackManagerRights
#ReturnRightsToManagers
#WeAreForManagerRights
#LetsRemindAboutMangers
#WeAreMangers
#MangersMustManage

The road to 1000 posts!
0 ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ 1000
80% complete

Banner Made By @Abcde26



Card Made By @Polygon

Powered by DjangoBB