Advertisement
UF6

German Tank Problem/ Panzer III variation

UF6
Aug 2nd, 2024
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.58 KB | Source Code | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. import seaborn as sns
  5.  
  6. # Known total production of Panzer III tanks
  7. total_production = 5774
  8.  
  9. # Monthly production data (approximation, replace with actual data if available)
  10. # Assuming production started in January 1939 and ended in December 1943
  11. months = pd.date_range(start='1939-01-01', end='1943-12-31', freq='M')
  12. monthly_production = np.random.poisson(lam=total_production/len(months), size=len(months))
  13.  
  14. # Adjust monthly production to ensure the total matches the known production number
  15. monthly_production = np.round(monthly_production * (total_production / monthly_production.sum())).astype(int)
  16.  
  17. monthly_data = {
  18.     'Month': months,
  19.     'Production': monthly_production
  20. }
  21.  
  22. variant_data = {
  23.     'Variant': ['Ausf. E', 'Ausf. F', 'Ausf. G', 'Ausf. H', 'Ausf. J'],
  24.     'Units': [1200, 1300, 1800, 2000, 2000]  # Example units, adjust based on actual data
  25. }
  26.  
  27. # Adjust variant units to match the total production
  28. variant_total = sum(variant_data['Units'])
  29. variant_data['Units'] = np.round(np.array(variant_data['Units']) * (total_production / variant_total)).astype(int)
  30.  
  31. # Create DataFrames
  32. df_monthly = pd.DataFrame(monthly_data)
  33. df_variant = pd.DataFrame(variant_data)
  34.  
  35. # Calculate proportion of each variant
  36. variant_total = df_variant['Units'].sum()
  37. df_variant['Proportion'] = df_variant['Units'] / variant_total
  38.  
  39. # Adjust for shortages (example shortage factors)
  40. shortage_factors = {
  41.     'manpower': 0.15,  # 15% reduction
  42.     'material': 0.10   # 10% reduction for specific variants
  43. }
  44.  
  45. # Adjust monthly production for shortages
  46. df_monthly['Production_Adjusted'] = df_monthly['Production'] * (1 - shortage_factors['manpower'])
  47.  
  48. # Adjust variant production for material shortages
  49. df_variant['Units_Adjusted'] = df_variant['Units'] * (1 - shortage_factors['material'])
  50.  
  51. # Output results
  52. print("\nAdjusted Monthly Production:")
  53. print(df_monthly)
  54.  
  55. print("\nAdjusted Variant Production:")
  56. print(df_variant)
  57.  
  58. # Example of serial number analysis
  59. serial_numbers = np.arange(101, 5875)  # Example serial numbers (replace with actual data if available)
  60. highest_serial_number = serial_numbers[-1]
  61. print(f"Highest Serial Number: {highest_serial_number}")
  62.  
  63. # Estimate total production based on highest serial number
  64. estimated_total_production = highest_serial_number + 1  # +1 if considering the last number observed
  65. print(f"Estimated Total Production (based on serial numbers): {estimated_total_production} tanks")
  66.  
  67. # Estimate total production for each variant (assuming the same proportion)
  68. df_variant['Estimated_Units'] = df_variant['Proportion'] * estimated_total_production
  69. print("\nEstimated Variant Production:")
  70. print(df_variant)
  71.  
  72. # Plotting Monthly Production
  73. plt.figure(figsize=(16, 8))
  74.  
  75. # Plot Aggregated Data
  76. plt.subplot(1, 2, 1)
  77. sns.lineplot(x='Month', y='Production', data=df_monthly, marker='o', label='Original Production')
  78. sns.lineplot(x='Month', y='Production_Adjusted', data=df_monthly, marker='o', color='red', linestyle='--', label='Adjusted Production')
  79. plt.title('Monthly Production of Panzer III Tanks (1939-1943)')
  80. plt.xlabel('Month')
  81. plt.ylabel('Production')
  82. plt.xticks(rotation=45)
  83. plt.grid(True)
  84. plt.legend()
  85.  
  86. # Plot Variant Production
  87. plt.subplot(1, 2, 2)
  88. sns.barplot(x='Variant', y='Units', data=df_variant, color='blue', label='Original Units')
  89. sns.barplot(x='Variant', y='Units_Adjusted', data=df_variant, color='red', alpha=0.5, label='Adjusted Units')
  90. plt.title('Production by Variant')
  91. plt.xlabel('Variant')
  92. plt.ylabel('Units')
  93. plt.legend()
  94.  
  95. plt.tight_layout()
  96. plt.show()
  97.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement