Coverage for src / cvx / risk / sample / __init__.py: 100%
1 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-13 06:46 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-13 06:46 +0000
1"""Sample covariance risk models for portfolio optimization.
3This subpackage provides the SampleCovariance class for risk estimation
4based on the sample covariance matrix.
6Example:
7 >>> import numpy as np
8 >>> from cvx.risk.sample import SampleCovariance
9 >>> model = SampleCovariance(num=3)
10 >>> model.update(
11 ... cov=np.eye(3),
12 ... lower_assets=np.zeros(3),
13 ... upper_assets=np.ones(3)
14 ... )
15 >>> risk = model.estimate(np.array([1/3, 1/3, 1/3]))
16 >>> isinstance(risk, float)
17 True
19Classes:
20 SampleCovariance: Risk model based on sample covariance matrix
22"""
24# Copyright 2023 Stanford University Convex Optimization Group
25#
26# Licensed under the Apache License, Version 2.0 (the "License");
27# you may not use this file except in compliance with the License.
28# You may obtain a copy of the License at
29#
30# http://www.apache.org/licenses/LICENSE-2.0
31#
32# Unless required by applicable law or agreed to in writing, software
33# distributed under the License is distributed on an "AS IS" BASIS,
34# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35# See the License for the specific language governing permissions and
36# limitations under the License.
37from .sample import SampleCovariance as SampleCovariance