<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Visual mathhammer for 8th edition
Introduction to plots
The charts and numbers below visually present the distribution of total wounds lost for various attack situations under 8th edition rules. The plots allow to get an intuitive sense of the importance of statlines, and also report the "expected" number of wounds, the number you would get on average if you keep repeating this situation. Each bar shows the probability of the targeted unit losing a certain number of wounds, after all rolls and checks. The expectation should be interpreted with caution — an expectation of x does not, in general, mean that in 50% of the cases the attacker will deal x or more damage.
Let us start with a simple case to illustrate the approach, here we consider a squad of 10 Guardsmen firing 10 Lasgun shots into an identical counterpart. The to chance hit is 3+, or 1 / 2, same for the chance to wound of S3 weapon into T3 models, and the a save of 5+ gives a probability of 4 / 6 for the wound to be left standing.
Step1:  As you can see, the squad has about 47% chance of scoring 1 or 0 hits and around 53% chance of scoring 2 or more hits. The expectation is 1.7, which is misleading
Step2:  The distribution shifted to the right, the chance to score 2+ hits went up to around 62%, but really the effect is negligible, with the re-roll still just as likely to miss as it is to hit. Now let's look at 'First Rank Fire!, Second Rank Fire!', which turns Lasguns into Rapid Fire 2 weapons
Step3:  A much stronger effect. You still cannot really rely on getting 3+ hits (~70% chance), but they will happen often enough and rarely would you get less than 2.
Now consider Veterans, who can shoot somewhat better and cost 6 points against 4 per a regular squaddie, what does that improvement in Ballistic Skill actually yield?
Step4:  Maybe not as much as one would think, the chance to score 2+ has gone up to around 68%, compared to the troop squad's 53%. If you have 60 points to spend, you are probably better off with 15 regular shots
<ASSISTANT_TASK:>
Python Code:
profiles[0] = {'shots': 10, 'p_hit': 1 / 2, 'p_wound': 1 / 2, 'p_unsaved': 4 / 6, 'damage': '1'}
profile_damage = damage_dealt(profiles[0])
wound_chart(profile_damage, profiles)
Explanation: Visual mathhammer for 8th edition
Introduction to plots
The charts and numbers below visually present the distribution of total wounds lost for various attack situations under 8th edition rules. The plots allow to get an intuitive sense of the importance of statlines, and also report the "expected" number of wounds, the number you would get on average if you keep repeating this situation. Each bar shows the probability of the targeted unit losing a certain number of wounds, after all rolls and checks. The expectation should be interpreted with caution — an expectation of x does not, in general, mean that in 50% of the cases the attacker will deal x or more damage.
Let us start with a simple case to illustrate the approach, here we consider a squad of 10 Guardsmen firing 10 Lasgun shots into an identical counterpart. The to chance hit is 3+, or 1 / 2, same for the chance to wound of S3 weapon into T3 models, and the a save of 5+ gives a probability of 4 / 6 for the wound to be left standing.
End of explanation
profiles[0]['p_hit'] = 0.583
wound_chart(damage_dealt(profiles[0]), profiles)
Explanation: As you can see, the squad has about 47% chance of scoring 1 or 0 hits and around 53% chance of scoring 2 or more hits. The expectation is 1.7, which is misleading: the squad actually has better than even odds of getting 2+ hits. The biggest takeaway  is that you can only really count on getting 1 hit, and even then you will be frustrated every sixth roll.
Let us take a look at how orders affect things. First we put our squad under 'Take Aim!' increasing the to hit chance to 0.583:
End of explanation
profiles[0]['p_hit'] = 0.5
profiles[0]['shots'] = 20
wound_chart(damage_dealt(profiles[0]), profiles)
Explanation: The distribution shifted to the right, the chance to score 2+ hits went up to around 62%, but really the effect is negligible, with the re-roll still just as likely to miss as it is to hit. Now let's look at 'First Rank Fire!, Second Rank Fire!', which turns Lasguns into Rapid Fire 2 weapons:
End of explanation
profiles[0]['shots'] = 10
profiles[0]['p_hit'] = 2 / 3
wound_chart(damage_dealt(profiles[0]), profiles)
Explanation: A much stronger effect. You still cannot really rely on getting 3+ hits (~70% chance), but they will happen often enough and rarely would you get less than 2.
Now consider Veterans, who can shoot somewhat better and cost 6 points against 4 per a regular squaddie, what does that improvement in Ballistic Skill actually yield?
End of explanation
profiles[0]['shots'] = 15
profiles[0]['p_hit'] = 1 / 2
wound_chart(damage_dealt(profiles[0]), profiles)
Explanation: Maybe not as much as one would think, the chance to score 2+ has gone up to around 68%, compared to the troop squad's 53%. If you have 60 points to spend, you are probably better off with 15 regular shots:
End of explanation
<END_TASK>