We want to generate a probability distribution for 4 states. The probability of each state is: 15%, 40%, 25%, and 20%. We only want to run this for 10 total trials however. Produce a matlab code that does this.
The following is a codeset that would accomplish this, explained after why this is very bruteforce, note, tab spacing does not work in this, so I if this is true in communication I would provide them with a picture of the file as well to see formating: prob1=15; prob2=40+prob1; prob3=25+prob2; prob4=20+prob3; count=[0 0 0 0]; %where we will store the number of times each state comes up N=10; %number of trials for i=1:N statep=randi([1,100]); %rolls a 100 sided dice if prob1<=statep count(1)=count(1)+1; elseif prob2<=statep count(2)=count(2)+1; elseif prob3<=statep count(3)=count(3)+1; else count(4)=count(4)+1; end end This program will work, but it is VERY brute force. If I was working with a student, I'd expect this type of thing as a starting code. If I provided the solution, I'd ask them how the code could be improved, as it is very brute force. The code works by rolling a number from 1-100, then checking the probabilities against that roll.
You are teaching a general chemistry lab. Your class is about to do a titration experiment, so you asked your TA to prepare some 1 molar NaOH and HCl mixtures for you from 5 molar stock solutions. When you arrive at lab 20 minutes early, your TA is in a panic, and explains to you that he didn't measure the water properly so he doesn't know what the molarity of the solutions are. In addition, he used all of the stock solution except 50 mL of the HCl solution! Just as you thought things couldn't get worse, your TA spills all of the indicator into the NaOH beaker! You tell your TA to go get more indicator before the class arrives, and that you'll come up with a way to solve this. Using only: the 50 mL of 5 molar HCl, DI water,the unknown molarity NaOH solution with indicator, and the unknown molarity HCl solution devise a way to find the molarity of the two solutions. The indicator will change color @ a PH of 7. For bonus points, for your first experiment use the 50 mL of 5 molar HCl as the titrant into 200 mL of a mixture of any of the available liquids.
Base solution: Do two titratoins. First, titrate the NaOH solution into the 50 mL of 5 molar HCl. As you know how many moles of HCl are in the 50 mL of 5 molar HCl (0.25 mols of HCl) the exact same amount of NaOH mols will be used after the indicator has changed color. After this is done, you can simply divide the number of mols (0.25 mols of NaOH) by the volume of NaOH solution used to calculate the molarity of the NaOH solution. Knowing the molarity of the NaOH solution, you can then use it to do the same experiment, except with the unkown molarity HCl solution to calculate its molarity as well. Bonus Point Change: Most the base solution applies. The notable change here is if you were to titrate 50 mL of the 5 molar HCl solution into, for example, 200 mL of the unknown NaOH solution the indicator may never change color. Say for example, the unknown solution had a molarity of 4. This means that the total amount of mols in the 200 mL of the NaOH solution would be 0.8 mols, while there is only 0.25 mols of HCl in the HCl solution. This means the indicator will never change color, as the PH will never drop below 7. To solve this problem, the NaOH solution can be diluted with either the water or the HCl solution. As we do not know the molarity of the HCl solution, we should use the DI water to dilute it. The "maximum" molarity the NaOH solution could be is 5 molar, as the stock was 5 molar. For this reason, we should ensure that if the unknown solution happened to be 5 molar, we diluted it enough to still change color. This means, at most, 50 mL of the NaOH solution should be added with 150 mL of the DI water to produce a 200 mL mixture.
Your long lost brother, Jimmy, comes to you with, what he claims to be, an amazing business proposition. He has recently come into acquisition of 50% Ethanol / 50% water mixture, and wants to sell it. You, being the wise chemical engineer you are, tell him that you could probably make more money if you purified it first. Jimmy doesn't understand the point of this, as he believes he can just sell it based on the weight of the ethanol sold and that this process will be expensive and require too many steps. Explain to Jimmy: 1) Why this purification process is potentially economically favorable 2) How you could acquire high purity ethanol with only one step (in this case step refers to unit operation) and 3) In this single unit operation what your expected purity would be. Remember, Jimmy is not a Chemical Engineer, so it is important that you communicate in such a way that he will understand you.
1) One of the main uses of ethanol is as a solvent, for example in things like paint. If you've ever added water to paint, you know full well that it loses its viscosity, or that is to say its "thickness" as a fluid. This makes it unusable for its intended purpose at this stage. If we do not purify the ethanol/water mixture, many of these companies will not want to buy our product, or will have to purify it themselves. 2) Ethanol have different vapor pressures, which is to say they have different tendencies to become a vapor. We can use distillation to create a vapor phase that has a higher concentration of ethanol, leaving behind a liquid phase with higher water concentration than the original 50/50 mixture.This process can be scaled using a distillation column, which is a column in which this process of separation happens at each tray, or level, or the column. This produces a fairly water pure exit at the bottom, and a fairly ethanol pure phase at the top. The exact purity will depend on how many stages, the temperature, and the rate at which we reflux, or recycle, the product back into the column to increase final product purity. 3) It should be noted that it may be advisable to have multiple columns to maximize purity and efficiency, however with a single column through distillation the maximum purity we could acquire is around 95.6% purity. However, it becomes more and more costly to push those last few percentages with distillation, so it would be advisable to expect something in the range of 90-95%, depending on the choices we make on the distillation column.