@Override
    public void init(String attributeName, Attribute.Type attributeType) {
        // Send the relevant attribute to this
        Attribute sum;
        Attribute count;
        Expression sumInitialValue;
        Expression countInitialValue;

        if (attributeName == null) {
            throw new SiddhiAppCreationException("Average incremental attribute aggregation cannot be executed " +
                    "when no parameters are given");
        }

        SumIncrementalAttributeAggregator sumIncrementalAttributeAggregator = new SumIncrementalAttributeAggregator();
        sumIncrementalAttributeAggregator.init(attributeName, attributeType);
        CountIncrementalAttributeAggregator countIncrementalAttributeAggregator =
                new CountIncrementalAttributeAggregator();
        countIncrementalAttributeAggregator.init(null, null);

        // Only one attribute exists for sum and count
        sum = sumIncrementalAttributeAggregator.getBaseAttributes()[0];
        count = countIncrementalAttributeAggregator.getBaseAttributes()[0];

        // Only one init value exists for sum and count
        sumInitialValue = sumIncrementalAttributeAggregator.getBaseAttributeInitialValues()[0];
        countInitialValue = countIncrementalAttributeAggregator.getBaseAttributeInitialValues()[0];

        this.baseAttributes = new Attribute[]{sum, count};
        this.baseAttributesInitialValues = new Expression[]{sumInitialValue, countInitialValue};
    }
{@link IncrementalAttributeAggregator} to calculate average based on an event attribute.
modules/siddhi-core/src/main/java/io/siddhi/core/query/selector/attribute/aggregator/incremental/AvgIncrementalAttributeAggregator.java