<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sarg.dev/index.php?action=history&amp;feed=atom&amp;title=Aggregate_pattern</id>
	<title>Aggregate pattern - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sarg.dev/index.php?action=history&amp;feed=atom&amp;title=Aggregate_pattern"/>
	<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Aggregate_pattern&amp;action=history"/>
	<updated>2026-04-14T08:27:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Aggregate_pattern&amp;diff=159761&amp;oldid=prev</id>
		<title>imported&gt;Giftlite: simplify</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Aggregate_pattern&amp;diff=159761&amp;oldid=prev"/>
		<updated>2025-02-12T02:53:20Z</updated>

		<summary type="html">&lt;p&gt;simplify&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Concepts in statistics and computer science}}&lt;br /&gt;
{{one source |date=March 2024}}&lt;br /&gt;
An &amp;#039;&amp;#039;&amp;#039;Aggregate pattern&amp;#039;&amp;#039;&amp;#039; can refer to concepts in either statistics or computer programming. Both uses simplify complexity into smaller, simpler parts.&lt;br /&gt;
&lt;br /&gt;
== Statistics ==&lt;br /&gt;
An aggregate pattern is an important statistical concept in many fields that rely on [[statistics]] to predict the behavior of large groups, based on the tendencies of subgroups to consistently behave in a certain way. It is particularly useful in [[sociology]], [[economics]], [[psychology]], and [[criminology]].&lt;br /&gt;
&lt;br /&gt;
== Computer programming ==&lt;br /&gt;
&lt;br /&gt;
In &amp;#039;&amp;#039;[[Design Patterns]]&amp;#039;&amp;#039;, an aggregate is not a [[Software design pattern|design pattern]] but rather refers to an object such as a list, vector, or generator which provides an interface for creating [[iterator]]s. The following example code is in [[Python (programming language)|Python]].&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def fibonacci(n: int):&lt;br /&gt;
    a, b = 0, 1&lt;br /&gt;
    count = 0&lt;br /&gt;
    while count &amp;lt; n:&lt;br /&gt;
        count += 1&lt;br /&gt;
        a, b = b, a + b&lt;br /&gt;
        yield a&lt;br /&gt;
&lt;br /&gt;
for x in fibonacci(10):&lt;br /&gt;
    print(x)&lt;br /&gt;
&lt;br /&gt;
def fibsum(n: int) -&amp;gt; int:&lt;br /&gt;
    total = 0&lt;br /&gt;
    for x in fibonacci(n):&lt;br /&gt;
        total += x&lt;br /&gt;
    return total&lt;br /&gt;
&lt;br /&gt;
def fibsum_alt(n: int) -&amp;gt; int:&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Alternate implementation. demonstration that Python&amp;#039;s built-in function sum()&lt;br /&gt;
    works with arbitrary iterators.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    return sum(fibonacci(n))&lt;br /&gt;
&lt;br /&gt;
myNumbers = [1, 7, 4, 3, 22]&lt;br /&gt;
&lt;br /&gt;
def average(g) -&amp;gt; float:&lt;br /&gt;
    return float(sum(g)) / len(g)  # In Python 3 the cast to float is no longer be necessary&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Python hides essentially all of the details using the [https://docs.python.org/3/library/stdtypes.html#iterator-types iterator protocol]. Confusingly, &amp;#039;&amp;#039;[[Design Patterns]]&amp;#039;&amp;#039; uses &amp;quot;aggregate&amp;quot; to refer to the blank in the code &amp;lt;code&amp;gt;for x in ___:&amp;lt;/code&amp;gt; which is unrelated to the term &amp;quot;aggregation&amp;quot;.&amp;lt;ref&amp;gt;[[Design Patterns]], p. 22: &amp;quot;Aggregation implies that one object owns or is responsible for another object. ... Aggregation implies that an aggregate object and its owner have identical lifetimes.&amp;quot;&amp;lt;/ref&amp;gt; Neither of these terms refer to the statistical aggregation of data such as the act of adding up the Fibonacci sequence or taking the average of a list of numbers.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Visitor pattern]]&lt;br /&gt;
* [[Template class]]&lt;br /&gt;
* [[Facade pattern]]&lt;br /&gt;
* [[Type safety]]&lt;br /&gt;
* [[Functional programming]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Software design patterns]]&lt;br /&gt;
[[Category:Articles with example Python (programming language) code]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{statistics-stub}}&lt;br /&gt;
{{compu-prog-stub}}&lt;/div&gt;</summary>
		<author><name>imported&gt;Giftlite</name></author>
	</entry>
</feed>