Coverage for src / cvx / risk / random / __init__.py: 100%
3 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-15 12:21 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-15 12:21 +0000
1"""Random data generation utilities for testing and simulation.
3This subpackage provides functions for generating random data useful for
4testing portfolio optimization algorithms.
6Example:
7 >>> import numpy as np
8 >>> from cvx.risk.random import rand_cov
9 >>> # Generate a random 5x5 covariance matrix
10 >>> cov = rand_cov(5, seed=42)
11 >>> cov.shape
12 (5, 5)
13 >>> # Verify positive semi-definite
14 >>> bool(np.all(np.linalg.eigvals(cov) >= -1e-10))
15 True
17Functions:
18 rand_cov: Generate a random positive semi-definite covariance matrix
20"""
22# Copyright 2023 Stanford University Convex Optimization Group
23#
24# Licensed under the Apache License, Version 2.0 (the "License");
25# you may not use this file except in compliance with the License.
26# You may obtain a copy of the License at
27#
28# http://www.apache.org/licenses/LICENSE-2.0
29#
30# Unless required by applicable law or agreed to in writing, software
31# distributed under the License is distributed on an "AS IS" BASIS,
32# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33# See the License for the specific language governing permissions and
34# limitations under the License.
35import importlib.metadata
37from .rand_cov import rand_cov as rand_cov # noqa: F401
39__version__ = importlib.metadata.version("cvxrisk")