Main Content

Results for

I got thoroughly nerd-sniped by this xkcd, leading me to wonder if you can use MATLAB to figure out the dice roll for any given (rational) probability. Well, obviously you can. The question is how. Answer: lots of permutation calculations and convolutions.
In the original xkcd, the situation described by the player has a probability of 2/9. Looking up the plot, row 2 column 9, shows that you need 16 or greater on (from the legend) 1d4+3d6, just as claimed.
If you missed the bit about convolutions, this is a super-neat trick
[v,c] = dicedist([4 6 6 6]);
bar(v,c)
% Probability distribution of dice given by d
function [vals,counts] = dicedist(d)
% d is a vector of number of sides
n = numel(d); % number of dice
% Use convolution to count the number of ways to get each roll value
counts = 1;
for k = 1:n
counts = conv(counts,ones(1,d(k)));
end
% Possible values range from n to sum(d)
maxtot = sum(d);
vals = n:maxtot;
end
Image Analyst
Image Analyst
Last activity on 24 Dec 2024

Attaching the Photoshop file if you want to modify the caption.
What better way to add a little holiday magic than the L-shaped membrane atop your evergreen? My colleagues output the shape and then added some thickness and an interior cylinder in Blender. Then, the shape was exported to STL and 3D printed (in several pieces). Then glued, sanded, primed, sanded again and painted. If you like, the STL file is attached. Thank you to https://blogs.mathworks.com/community/2013/06/20/paul-prints-the-l-shaped-membrane/ and a tip of the hat to MATLAB Ornament. Happy Holidays!
Image Analyst
Image Analyst
Last activity on 2 Dec 2024

Christmas season is underway at my house:
(Sorry - the ornament is not available at the MathWorks Merch Shop -- I made it with a 3-D printer.)
I know we have all been in that all-too-common situation of needing to inefficiently identify prime numbers using only a regular expression... and now Matt Parker from Standup Maths helpfully released a YouTube video entitled "How on Earth does ^.?$|^(..+?)\1+$ produce primes?" in which he explains a simple regular expression (aka Halloween incantation) which matches composite numbers:
Here is my first attempt using MATLAB and Matt Parker's example values:
fnh = @(n) isempty(regexp(repelem('*',n),'^.?$|^(..+?)\1+$','emptymatch'));
fnh(13)
ans = logical
1
fnh(15)
ans = logical
0
fnh(101)
ans = logical
1
fnh(1000)
ans = logical
0
Feel free to try/modify the incantation yourself. Happy Halloween!
David
David
Last activity on 12 Sep 2024

In case you haven't come across it yet, @Gareth created a Jokes toolbox to get MATLAB to tell you a joke.
Hi All,
I'm currently verifying a global sensitivity analysis done in SimBiology and I'm a touch confused. This analysis was run with every parameter and compartment volume in the model. To my understanding the fraction of unexplained variance is 1 - the sum of the first order variances, therefore if the model dynamics are dominated by interparameter effects you might see a higher fraction of unexplained variance. In this analysis however, as the attached figure shows (with input at t=20 minutes), the most sensitive four parameters seem to sum, in first order sensitivities to roughly one at each time point and the total order sensitivies appear nearly identical. So how is the fraction of unexplained variance near one?
Thank you for your help!
Image Analyst
Image Analyst
Last activity on 12 Aug 2024

Imagine that the earth is a perfect sphere with a radius of 6371000 meters and there is a rope tightly wrapped around the equator. With one line of MATLAB code determine how much the rope will be lifted above the surface if you cut it and insert a 1 meter segment of rope into it (and then expand the whole rope back into a circle again, of course).
Hi to everyone!
To simplify the explanation and the problem, I simulated the kinetics of an irreversible first-order reaction, A -> B. I implemented it in two independent compartments, R and P. I simulated the effect of a dilution in R by doubling at t= 0,1 the R volume. I programmed in P that, at t = 0.1, the instantaneous concentration of A and B would be reduced by half. I am sending an attach with the implementation of these simulations in the Simbiology interface.
When the simulations of the two compartments are plotted, it can be seen that the responses are not equal. That is, from t = 0.1 s, the reaction follow an exponential function in R with half of the initial amplitude and half of the initial value of k1. That is, the relaxation time is doubled. Meanwhile, in P, from t = 0.1, the reaction follows exponential kinetics with half the amplitude value but maintaining the initial value of k = 10. Without a doubt, the correct simulation is the latter (compartment P) where only the effect is observed in the amplitude and not in the relaxation time. Could you tell me what the error is that makes these kinetics that should be equal not be?
Thank you in advance!
Luis B.
Hi All,
I've been producing a QSP model of glucose homeostasis for a while now for my PhD project, recently I've been able to expand it to larger time series, i.e. 2 days of data rather than a singular injection or a singular meal. My problem is as follows: If I put 75g of glucose into my stomach glucose species any later than (exactly) 8.5 hours I get an integration tolerance error. Curiosly, I can put 25g of glucose in at any time up to 15.9 hours, then any later an error. I have disabled all connections to my glucose absorption chain, i.e. stomach -> duodenum -> jenenum -> ileum -> removal, to isolate the cause of this. I had initially thought it may be because I mechanistically model liver glycogen and that does deplete over time, but I've tested enough to show that that does nothing. My next test is to isolate the glucose absorption chain into a seperate model and see if the issue persists but I'm completely baffled!
These are the equations, to my eye there's no reason why there would be such a sharp glucose quantity/time dependence, they all begin at a value of 0:
d(Gs)/dt = -(kw*(1-Gd^14/(Igd^14+Gd^14))*Gs) #Stomach glucose
d(Gd)/dt = (kw*(1-Gd^14/(Igd^14+Gd^14))*Gs) - (kdj*Gd) #Duodenal Glucose
d(Gj)/dt = (kdj*Gd) - (kji*Gj) #Jejunal Glucose
d(Gi)/dt = (kji*Gj) - (kic*Gi) #Ileal Glucose
(The sigmoidicity of gastric emptying slowing term (^14) was parameterised off of paracetamol absorption data and appears to be correct!)
Thank you for your help, best regards,
Dan
Pre-Edit: I changed the run time to 30 hours and now I can't use the 75g input any later than 7.9 hours not 8.5 hours anymore!
Edit: This is how it appears at all times prior to it failing for 75g:
Hans Scharler
Hans Scharler
Last activity on 31 May 2024

Spring is here in Natick and the tulips are blooming! While tulips appear only briefly here in Massachusetts, they provide a lot of bright and diverse colors and shapes. To celebrate this cheerful flower, here's some code to create your own tulip!
Chen Lin
Chen Lin
Last activity on 9 Jun 2024

Drumlin Farm has welcomed MATLAMB, named in honor of MathWorks, among ten adorable new lambs this season!
I found this plot of words said by different characters on the US version of The Office sitcom. There's a sparkline for each character from pilot to finale episode.
Today, he got dressed for work to design some new dog toy-making algorithms. #nationalpetday
Transforming my furry friend into a grayscale masterpiece with MATLAB! 🐾 #MATLABPetsDay
This is Stella while waiting to see if the code works...