Repository navigation
Expand file tree
/
Copy pathCalibration.py
More file actions
67 lines (47 loc) · 1.5 KB
/
Copy pathCalibration.py
File metadata and controls
67 lines (47 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# ---------------------------
# INPUTS
# ---------------------------
# Example: load your utilization data
# Replace with your actual file / column
df = pd.read_excel("Flattened Parking Count Data_YC_with plot.xlsx")
# Assume you already computed utilization column (0–1 scale)
# If not, define it like:
# df["utilization"] = df["occupancy"] / capacity
util = df["utilization"].dropna().values
# Survey PPR (example for Yacht Club)
PPR = 0.2854 # 28.54%
# ---------------------------
# SURVIVAL FUNCTION
# ---------------------------
# Sort utilization values
u_vals = np.sort(util)
# Compute survival function S(u) = P(U >= u)
survival = 1 - np.arange(len(u_vals)) / len(u_vals)
# ---------------------------
# FIND THRESHOLD u*
# ---------------------------
# Find closest match where survival ≈ PPR
idx = np.argmin(np.abs(survival - PPR))
u_star = u_vals[idx]
print(f"Behavioral threshold u*: {u_star:.3f}")
# ---------------------------
# PLOT
# ---------------------------
plt.figure(figsize=(7,5))
# Survival curve
plt.plot(u_vals, survival, label="Survival Function P(U ≥ u)")
# Horizontal PPR line
plt.axhline(PPR, linestyle="--", label=f"PPR = {PPR:.2f}")
# Vertical threshold line
plt.axvline(u_star, linestyle="--", label=f"u* = {u_star:.2f}")
# Intersection point
plt.scatter([u_star], [PPR])
plt.xlabel("Utilization (u)")
plt.ylabel("P(U ≥ u)")
plt.title("Calibration Curve: Yacht Club")
plt.legend()
plt.grid(True)
plt.show()