用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/a5c-ai/babysitter --skill work-sampling-analyzer命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | work-sampling-analyzer |
| description | Work sampling analysis skill for activity distribution and utilization studies. |
| allowed-tools | Bash(*) Read Write Edit Glob Grep WebFetch |
| metadata | {"author":"babysitter-sdk","version":"1.0.0","category":"work-measurement","backlog-id":"SK-IE-035"} |
| graph | {"domains":["domain:industrial-engineering"],"skillAreas":["skill-area:statistical-analysis","skill-area:organizational-design","skill-area:data-analysis"],"roles":["role:operations-analyst","role:research-engineer"]} |
You are work-sampling-analyzer - a specialized skill for work sampling studies to analyze activity distribution and equipment/worker utilization.
This skill enables AI-powered work sampling including:
import numpy as np
from scipy import stats
import random
from datetime import datetime, timedelta
def determine_sample_size_binomial(estimated_proportion: float,
desired_accuracy: float,
confidence_level: float = 0.95):
"""
Determine required sample size for work sampling
estimated_proportion: estimated percentage of time in activity (as decimal)
desired_accuracy: desired accuracy (e.g., 0.05 for ±5%)
confidence_level: statistical confidence (typically 0.95)
"""
p = estimated_proportion
e = desired_accuracy
z = stats.norm.ppf(1 - (1 - confidence_level) / 2)
# n = (z² × p × (1-p)) / e²
n = (z ** 2 * p * (1 - p)) / (e ** 2)
return {
"required_observations": int(np.ceil(n)),
"estimated_proportion": p,
"desired_accuracy": f"±{e * 100:.1f}%",
"confidence_level": f"{confidence_level * 100:.0f}%",
"z_score": round(z, 2)
}
def update_sample_size(observations: int, observed_proportion: float,
desired_accuracy: float, confidence_level: float = 0.95):
"""
Update sample size based on observed data
"""
z = stats.norm.ppf(1 - (1 - confidence_level) / 2)
# Recalculate with observed proportion
p = observed_proportion
required = int(np.ceil((z ** 2 * p * (1 - p)) / (desired_accuracy ** 2)))
return {
"current_observations": observations,
"observed_proportion": round(p, 3),
"required_observations": required,
"additional_needed": max(0, required - observations),
"study_complete": observations >= required
}
def generate_random_schedule(study_duration_days: int,
observations_per_day: int,
work_start: str = "08:00",
work_end: str = "17:00",
exclude_lunch: tuple = ("12:00", "13:00")):
"""
Generate random observation times for work sampling study
"""
start_time = datetime.strptime(work_start, "%H:%M")
end_time = datetime.strptime(work_end, "%H:%M")
lunch_start = datetime.strptime(exclude_lunch[0], "%H:%M")
lunch_end = datetime.strptime(exclude_lunch[1], "%H:%M")
schedule = []
for day in range(study_duration_days):
day_schedule = []
# Generate random times
attempts = 0
while len(day_schedule) < observations_per_day and attempts < 1000:
# Random minutes from start to end
total_minutes = (end_time - start_time).seconds // 60
random_minutes = random.randint(0, total_minutes)
obs_time = start_time + timedelta(minutes=random_minutes)
# Check if during lunch
if lunch_start <= obs_time < lunch_end:
attempts += 1
continue
# Check minimum spacing (10 minutes)
too_close = False
for existing day_schedule:
((obs_time - existing).seconds) < :
too_close =
too_close:
day_schedule.append(obs_time)
attempts +=
day_schedule.sort()
schedule.append({
: day + ,
: [t.strftime() t day_schedule]
})
{
: study_duration_days,
: observations_per_day,
: study_duration_days * observations_per_day,
: schedule
}
def analyze_observations(observations: list, categories: list):
"""
Analyze work sampling observations
observations: list of observed categories
categories: list of possible categories
"""
total = len(observations)
# Count by category
counts = {cat: observations.count(cat) for cat in categories}
# Calculate proportions and confidence intervals
z = stats.norm.ppf(0.975) # 95% confidence
results = []
for cat in categories:
count = counts[cat]
p = count / total if total > 0 else 0
# Standard error
se = np.sqrt(p * (1 - p) / total) if total > 0 else 0
# Confidence interval
ci_lower = max(0, p - z * se)
ci_upper = min(1, p + z * se)
results.append({
'category': cat,
'count': count,
'proportion': round(p, 4),
'percentage': round(p * 100, 1),
'std_error': round(se, 4),
'ci_95_lower': round(ci_lower * 100, ),
: (ci_upper * , )
})
results.sort(key= x: x[], reverse=)
{
: total,
: results,
: {
: (r[] r results
r[].lower()
r[].lower()) * ,
: (r[] r results
r[].lower()
r[].lower()) *
}
}
def create_sampling_control_chart(daily_observations: list,
target_proportion: float = None):
"""
Create control chart to monitor sampling consistency
daily_observations: list of {'day': int, 'productive': int, 'total': int}
"""
# Calculate overall average
total_productive = sum(d['productive'] for d in daily_observations)
total_obs = sum(d['total'] for d in daily_observations)
p_bar = total_productive / total_obs if total_obs > 0 else 0
# Calculate control limits for each day (variable sample size)
chart_data = []
for day_data in daily_observations:
n = day_data['total']
p = day_data['productive'] / n if n > 0 else 0
# Standard error
se = np.sqrt(p_bar * (1 - p_bar) / n) if n > 0 else 0
# 3-sigma control limits
ucl = min(1, p_bar + 3 * se)
lcl = max(0, p_bar - 3 * se)
# Check if in control
in_control = lcl <= p <= ucl
chart_data.append({
'day': day_data['day'],
: (p, ),
: n,
: (ucl, ),
: (lcl, ),
: in_control
})
ooc_points = [d d chart_data d[]]
{
: (p_bar, ),
: chart_data,
: (ooc_points),
: (ooc_points) == ,
: (ooc_points) ==
}
def calculate_standard_time_from_sampling(sampling_results: dict,
total_study_time_hours: float,
units_produced: int,
allowance_percent: float):
"""
Develop standard time from work sampling data
sampling_results: results from analyze_observations
total_study_time_hours: total time covered by study
units_produced: number of units produced during study
allowance_percent: PFD allowance
"""
# Find productive time proportion
productive_proportion = sampling_results['summary']['productive'] / 100
# Total productive time
productive_hours = total_study_time_hours * productive_proportion
# Normal time per unit
normal_time_hours = productive_hours / units_produced if units_produced > 0 else 0
normal_time_minutes = normal_time_hours * 60
# Apply allowances
allowance_factor = 1 + (allowance_percent / 100)
standard_time_minutes = normal_time_minutes * allowance_factor
return {
"study_duration_hours": total_study_time_hours,
"productive_proportion": round(productive_proportion, 3),
"productive_hours": round(productive_hours, 2),
"units_produced": units_produced,
"normal_time_per_unit": round(normal_time_minutes, 3),
"allowance_percent": allowance_percent,
"standard_time_per_unit": (standard_time_minutes, ),
: ( / standard_time_minutes, ) standard_time_minutes >
}
def multi_activity_study(observations: list, workers: list, machines: list):
"""
Analyze multi-activity work sampling with workers and machines
observations: list of {'time': str, 'worker': str, 'activity': str, 'machine': str}
"""
total_obs = len(observations)
# Analyze by worker
worker_analysis = {}
for worker in workers:
worker_obs = [o for o in observations if o['worker'] == worker]
n = len(worker_obs)
activities = {}
for obs in worker_obs:
act = obs['activity']
activities[act] = activities.get(act, 0) + 1
worker_analysis[worker] = {
'observations': n,
'activities': {k: {'count': v, 'percent': round(v / n * 100, 1)}
for k, v in activities.items()}
}
# Analyze by machine
machine_analysis = {}
for machine in machines:
machine_obs = [o for o in observations if o.get('machine') == machine]
n = len(machine_obs)
states = {}
for obs in machine_obs:
state = obs.get('machine_state', 'running')
states[state] = states.get(state, ) +
n > :
machine_analysis[machine] = {
: n,
: {k: {: v, : (v / n * , )}
k, v states.items()},
: (states.get(, ) / n * , )
}
{
: total_obs,
: worker_analysis,
: machine_analysis,
: {
: np.mean([
- w[].get(, {}).get(, )
w worker_analysis.values()
]),
: np.mean([
m[] m machine_analysis.values()
]) machine_analysis
}
}
This skill integrates with the following processes:
work-measurement-analysis.jsutilization-improvement.jsworkforce-planning.js{
"study_summary": {
"total_observations": 500,
"study_duration_days": 10,
"confidence_level": "95%"
},
"activity_analysis": {
"productive": {"percent": 72.5, "ci": [68.5, 76.5]},
"idle": {"percent": 15.2, "ci": [12.1, 18.3]},
"delay": {"percent": 12.3, "ci"