```python
import numpy as np
import matplotlib.pyplot as plt
from numpy.random import default_rng
plt.style.use('fivethirtyeight')
```
# HW_05 - Customer wait time
In the [waiting for bus](./bus_wait.ipynb) example, we saw a difference between how long we expect the bus interval to be vs how long we _experience_ a bus interval to be.
Now, consider creating parts on demand for customers. We'll take an example of [folding a paper airplane](https://hackmd.io/@cooperrc/HkISHYNrC/edit). We need some data to start:
1. Follow the paper airplane instructions and make one airplane
2. Edit the instructions to make it easier to follow
3. With your new process: time yourself making one airplane at-a-time and make 5 or 6 airplanes
4. With one hand, try to make a paper airplane and time the process (time process this at least 2 times)
## What is this data meant to show
We, engineers, often prescribe processes and procedures that seem to make sense, but can ignore the people that need to do the work. The process of create-try-edit-repeat should be an integral part of your writing and design process. The one-handed folding procedure could simulate many scenarios:
- someone multitasking
- someone with an injury/unuseable hand
- anything else?
When we consider a process, its important to think about the different people that are required to make the process happen.
## Next steps
With your times recorded, you can use the average and standard deviations to find the times when parts will be ready as a function of time. Use the difference between the predicted and observed cumulative distribution functions to predict how long your customers will have to wait on paper airplanes.
```python
fold_01 = np.array([45, 55, 30, 35, 40])
fold_02 = np.array([75, 90])
print(np.mean(fold_01), np.std(fold_01))
print(np.mean(np.hstack([fold_01, fold_02])),
np.std(np.hstack([fold_01, fold_02])))
```
41.0 8.602325267042627
52.857142857142854 20.503857277724748
```python
N_assemblies = 1000
avg_part_time = 52.9 #np.mean(fold_01)
part_ready = np.arange(1, N_assemblies+1)*avg_part_time
rng = default_rng(42)
std_part_time = 20.5 #np.std(fold_01)
part_ready += rng.normal(loc = 0,
scale = std_part_time,
size = N_assemblies)
part_ready.sort()
plt.hist(np.diff(part_ready), density=True)
plt.xlabel('time between parts (sec)')
```
Text(0.5, 0, 'time between parts (sec)')

```python
part_time_diff = np.diff(part_ready)
count, bins_count = np.histogram(part_time_diff, bins=50)
pdf = count / sum(count)
cdf = np.cumsum(pdf)
plt.plot(bins_count[1:], cdf)
plt.hlines([0, 0.25, 0.5, 0.75, 1],
0,
100,
alpha = 0.2,
colors = 'r')
plt.title('Cumulative Distribution of part intervals')
plt.ylabel('relative count')
plt.xlabel('seconds between parts')
```
Text(0.5, 0, 'seconds between parts')

```python
num_people = 500
people_arrival = rng.random(num_people)*N_assemblies*avg_part_time
```
```python
person_wait = np.zeros(len(people_arrival))
obs_part_interval = np.zeros((len(part_ready), 2))
for i, part_time in enumerate(part_ready[:-1]):
people_get_part = np.size(people_arrival[
np.logical_and(people_arrival>=part_time,
people_arrival<part_ready[i+1])])
obs_part_interval[i, 0] = part_ready[i+1] - part_time
obs_part_interval[i, 1] = people_get_part
```
```python
obs_part_interval = obs_part_interval[obs_part_interval[:, 0].argsort()]
```
```python
plt.plot(bins_count[1:],
cdf,
label = 'CDF measured'
)
cdf_obs = np.cumsum(obs_part_interval[:, 1])/num_people
plt.plot(obs_part_interval[:, 0],
cdf_obs,
'r-',
label = 'CDF observed')
plt.hlines([0, 0.25, 0.5, 0.75, 1],
0,
100,
alpha = 0.2,
colors = 'r')
plt.title('Cumulative Distribution of part intervals')
plt.ylabel('relative count')
plt.xlabel('minutes between parts')
```
Text(0.5, 0, 'minutes between parts')

This report examines the customer wait time in a simulated paper airplane production environment.
The primary focus is on understanding the variability in production times and its impact on customer wait times. This simulation is a proof-of-concept for manufacturing process analysis. In this report, we create and modify the process for making paper airplanes. We measure the time taken to complete paper airplanes under two conditions two-handed assembly and one-handed assembly.
One-handed assembly simulates multitasking or
physical disability.
First, a baseline was created by making one paper airplane
according to standard instructions. The guidelines were then revised to improve their readability and clarity. Then, using the revised instructions, five to six airplanes were built, with each assembly timed to collect data on the new procedure. The assemblies were timed 5 and 2 times for two-handed and one-handed procedures.
----
_End of Youtube edits_
----
Initial Data Collection:
I recorded the times taken to fold paper airplanes in five iterations: 138, 128, 126, 107, and 104
seconds. The average time per airplane was calculated to be approximately 120.6 seconds with a
standard deviation of 13 seconds.
The code uses a base value of 1000 assemblies for when the airplanes would be ready. The time for
each airplane was determined as ff×2.00217 where ff is the airplane’s sequence number.
To simulate realistic production conditions, there is normally distributed noise in the part ready
times with a standard deviation of 13 seconds (converted to minutes).
Then, the simulated 500 customers arrived randomly over the production period. Each customer’s
arrival time was generated uniformly across the total production time. The interval between consecutive airplane completions and the number of customers arriving within each interval is calculated.
Each customer’s wait time was determined by the difference between their arrival time and the
next available airplane completion time.
CDF of Measured Part Intervals:
The intervals between airplane completions were used to calculate a probability density function
(PDF) and a CDF, providing a distribution of part intervals over time. The observed part intervals
were sorted, and the cumulative number of customers receiving airplanes within these intervals was
used to calculate the observed CDF. I compared the measured and observed CDFs to evaluate the
accuracy of the production predictions and understand the impact of variability on customer wait
The paper airplane folding experiment underscores a fundamental principle in engineering design: the importance of considering the human factor in process development. It reveals that theoretical efficiency can lead to different practical outcomes. Engineers must understand the human context in which their creations operate, ensuring designs are not only technically sound but also universally beneficial.
By incorporating this holistic approach, engineers ensure their designs are robust, user-friendly, and adaptable to diverse user needs. Embracing comprehensive design thinking not only leads to better systems but also fosters innovation and inclusivity, proving indispensable in practical applications. This method ensures that engineering solutions are effective in real-world settings, meeting the diverse requirements of all users and making processes more accessible and efficient.
```python
```