Mean

PortfolioOptimisers.SimpleExpectedReturnsType
struct SimpleExpectedReturns{T1} <: AbstractExpectedReturnsEstimator
    w::T1
end

A simple expected returns estimator for PortfolioOptimisers.jl, representing the sample mean with optional observation weights.

SimpleExpectedReturns is the standard estimator for computing expected returns as the (possibly weighted) mean of asset returns. It supports both unweighted and weighted mean estimation by storing an optional weights vector.

Fields

  • w::Union{Nothing, <:AbstractWeights}: Optional weights for each observation. If nothing, the unweighted mean is computed.

Constructor

SimpleExpectedReturns(; w::Union{Nothing, <:AbstractWeights} = nothing)

Construct a SimpleExpectedReturns estimator with optional observation weights.

Fields

  • w::Union{Nothing, <:AbstractWeights}: Optional weights for each observation.

Related

source
PortfolioOptimisers.SimpleExpectedReturnsMethod
SimpleExpectedReturns(; w::Union{Nothing, <:AbstractWeights} = nothing)

Construct a SimpleExpectedReturns estimator for computing expected returns as the (optionally weighted) sample mean.

Arguments

  • w::Union{Nothing, <:AbstractWeights}: Optional observation weights. If nothing, the unweighted mean is computed.

ReturnsResult

  • SimpleExpectedReturns: A simple expected returns estimator configured with optional weights.

Validation

  • If w is provided, it must not be empty.

ReturnsResult

  • SimpleExpectedReturns: A simple expected returns estimator.

Examples

julia> using StatsBase

julia> ser = SimpleExpectedReturns()
SimpleExpectedReturns
  w | nothing

julia> w = Weights([0.2, 0.3, 0.5]);

julia> ser = SimpleExpectedReturns(; w = w)
SimpleExpectedReturns
  w | StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.2, 0.3, 0.5]

Related

source
Statistics.meanMethod
mean(me::SimpleExpectedReturns, X::AbstractArray; dims::Int = 1, kwargs...)

Compute the mean of asset returns using a SimpleExpectedReturns estimator.

This method computes the expected returns as the sample mean of the input data X, optionally using observation weights stored in the estimator. If no weights are provided, the unweighted mean is computed.

Arguments

  • me::SimpleExpectedReturns: The expected returns estimator.
  • X::AbstractArray: Data array of asset returns (observations × assets).
  • dims: Dimension along which to compute the mean.
  • kwargs...: Additional keyword arguments passed to Statistics.mean.

ReturnsResult

Examples

julia> using StatsBase

julia> X = [0.01 0.02; 0.03 0.04];

julia> ser = SimpleExpectedReturns()
SimpleExpectedReturns
  w | nothing

julia> mean(ser, X)
1×2 Matrix{Float64}:
 0.02  0.03

julia> w = Weights([0.2, 0.8]);

julia> serw = SimpleExpectedReturns(; w = w)
SimpleExpectedReturns
  w | StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.2, 0.8]

julia> mean(serw, X)
1×2 Matrix{Float64}:
 0.026  0.036

Related

source