By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Diversification is the practice of spreading investments, resources, or dependencies across multiple uncorrelated assets, systems, or strategies to reduce risk. You use it today to avoid catastrophic failure when a single component, market, or dependency collapses—whether in finance, robotics, automation, or AI.
Without diversification, a single point of failure can break your entire system.
Goal: Allocate funds across uncorrelated assets to minimize risk.
import numpy as np import pandas as pd import yfinance as yf from scipy.optimize import minimize # Fetch historical data for uncorrelated assets tickers = ["SPY", "BND", "GLD", "QQQ"] # US stocks, bonds, gold, tech data = yf.download(tickers, start="2020-01-01", end="2023-01-01")["Adj Close"] returns = data.pct_change().dropna() # Calculate expected returns and covariance matrix expected_returns = returns.mean() * 252 # Annualized cov_matrix = returns.cov() * 252 # Objective: Minimize portfolio variance (risk) def portfolio_variance(weights): return weights.T @ cov_matrix @ weights # Constraints: Weights sum to 1, no shorting constraints = {"type": "eq", "fun": lambda w: np.sum(w) - 1} bounds = [(0, 1) for _ in range(len(tickers))] # Optimize initial_weights = np.array([0.25, 0.25, 0.25, 0.25]) result = minimize( portfolio_variance, initial_weights, method="SLSQP", bounds=bounds, constraints=constraints, ) optimal_weights = result.x print("Optimal weights:") for ticker, weight in zip(tickers, optimal_weights): print(f"{ticker}: {weight:.2%}")
Expected Outcome:- A portfolio with weights like: - SPY (US stocks): 40% - BND (bonds): 30% - GLD (gold): 15% - QQQ (tech): 15% - Lower volatility than an all-stock portfolio.
SPY (US stocks): 40%
BND (bonds): 30%
GLD (gold): 15%
QQQ (tech): 15%
Goal: Combine LiDAR and camera data to improve obstacle detection.
import numpy as np # Simulated sensor data (distance to obstacle in meters) lidar_data = np.array([5.0, 4.9, 5.1, 100.0]) # 100 = error (e.g., rain) camera_data = np.array([4.8, 4.7, 5.2, 4.5]) # Camera works in rain # Sensor reliability weights (higher = more trust) lidar_weight = 0.7 if np.median(lidar_data) < 10 else 0.1 # LiDAR fails in rain camera_weight = 0.3 if lidar_weight > 0.5 else 0.9 # Fuse data using weighted average fused_data = (lidar_data * lidar_weight + camera_data * camera_weight) / (lidar_weight + camera_weight) print("Fused distances:", fused_data)
Expected Outcome:- In clear weather: fused_data ≈ [4.94, 4.84, 5.12, 100.0] (LiDAR dominates).- In rain: fused_data ≈ [4.8, 4.7, 5.2, 4.5] (camera dominates).
fused_data ≈ [4.94, 4.84, 5.12, 100.0]
fused_data ≈ [4.8, 4.7, 5.2, 4.5]
Goal: Combine predictions from multiple models to improve accuracy.
from sklearn.datasets import load_iris from sklearn.ensemble import VotingClassifier from sklearn.linear_model import LogisticRegression from sklearn.tree import DecisionTreeClassifier from sklearn.svm import SVC from sklearn.model_selection import train_test_split # Load data data = load_iris() X, y = data.data, data.target X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) # Train diverse models models = [ ("lr", LogisticRegression(max_iter=200)), ("dt", DecisionTreeClassifier()), ("svm", SVC(probability=True)), ] # Create ensemble ensemble = VotingClassifier(models, voting="soft") ensemble.fit(X_train, y_train) # Evaluate print("Ensemble accuracy:", ensemble.score(X_test, y_test))
Expected Outcome:- Higher accuracy than any single model (e.g., 98% vs. 95% for the best individual model).
You’re building a self-driving car. Which sensor combination best diversifies risk? A) Two identical LiDAR sensors B) LiDAR + radar + camera C) Only cameras (like Tesla) D) LiDAR + ultrasonic sensors
Correct Answer: B Explanation: LiDAR + radar + camera cover each other’s weaknesses (e.g., LiDAR fails in rain, cameras fail in darkness, radar works in all conditions).Why the Distractors Are Tempting:- A: Redundancy, but both sensors fail under the same conditions (e.g., rain).- C: Tesla’s approach, but cameras alone struggle in low light.- D: LiD
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.