Wavg

The Wavg function returns the weighted average of all values in the given expression for a given weighting formula.

The Wavg function offers two different overloads.

Name Description
Wavg (expression, weightingFormula) Returns the weighted average of all values in the given expression and weighted by the given weighting formula.
Wavg (expression, weightingFormula, filter) Returns the weighted average of all values in the given expression, weighted by the given weighting formula and where the given filter is true.

Wavg(expression, weightingFormula)

The Wavg(expression, weightingFormula) function returns the weighted average of all values in the given expression and weighted by the given weighting formula. It is used to return the weighted average of the selected item over all the blocks in the block model.

This is the same as Wavg (expression, weightingFormula, filter) but without a cutoff or ore filter being applied.

Wavg(expression, weightingFormula, filter)

The Wavg(expression, weightingFormula, filter) function returns the weighted average of all values in the given expression, weighted by the given weighting formula and where the given filter is true. It is used to return the weighted average of the selected item over all the blocks in the block model.

For example, the formula could be used to calculate the average iron grade in a block model. Let's say the block model consists of a Topo percent and one ore parcel with the ore percent represented by the item ore percent. Therefore the tonnes in a single block gets calculated as follows:

blocktonnes = define(block.BlockVolume * block.OrePercent * block.Topo * block.SG)

Then, define the cutoff:

cutoff = define(block.Fe > 50)

Now, calculate the average Fe grade:

fegrade = wavg(block.Fe, blocktonnes, cutoff)

The final formula is as follows:

blocktonnes = define(block.BlockVolume * block.OrePercent * block.Topo * block.SG)
cutoff = define(block.Fe > 50)
fegrade = wavg(block.Fe, blocktonnes, cutoff)