Latest / Talk Python To Me / #372: Applied mathematics with Python
Transcript
- 0:00Often when we learn about or work with math, it's done so in a very detached style.
- 0:05You might learn the rules or techniques of differentiation, for example,
- 0:09but how often do you get to apply them to meaningful and interesting problems?
- 0:14In this episode, we have Vincent Knight and Grant Palmer on to discuss a wide variety of
- 0:20applied and approachable math problems using Python. Whether you're deeply into math or
- 0:25not so much, I think there's a lot to enjoy from this episode.
- 0:29This is Talk Python To Me, episode 372, recorded June 29th, 2022.
- 0:34Welcome to Talk Python To Me, a weekly podcast on Python. This is your host, Michael Kennedy.
- 0:52Follow me on Twitter where I'm @mkennedy and keep up with the show and listen to past episodes
- 0:58talkpython.fm and follow the show on Twitter via at Talk Python. We've started streaming most of our
- 1:03episodes live on YouTube. Subscribe to our YouTube channel over at talkpython.fm/youtube to get
- 1:09notified about upcoming shows and be part of that episode. This episode of Talk Python is brought to
- 1:15you by Compiler from Red Hat. Listen to an episode of their podcast to demystify the tech industry over
- 1:22talkpython.fm/compiler. And we'll see you next time on Twitter. And we'll see you next time on Twitter.
- 1:34A quick announcement before we jump into the show. You probably know about our video courses. I'm super
- 2:00super proud of them and they're a fantastic educational resource for many people. But sometimes you can
- 2:06benefit from a more hands-on, group-based approach. That's why I'm running another online cohort course.
- 2:13This one will cover FastAPI, Async Python programming, and MongoDB. However, the structure is different this
- 2:20time around. This course will be taught 100% live in person. You'll attend over Zoom and all the sessions will
- 2:27include myself as an instructor and your fellow students. It runs from August 8th to August 19th.
- 2:34If that sounds interesting, please check out the link in your podcast player show notes or on the episode
- 2:38page. And if your company offers educational credits or training reimbursements, you should be able to
- 2:44expense this course as well as our regular Talk Python courses. I'll put some links to templates that you can
- 2:51use to help with that in the show notes as well. Vince Grant, welcome to Talk Python To Me.
- 2:56Thanks, Michael. Thank you very much for having us. Thank you.
- 2:58Yeah, thanks. Nice to be here.
- 2:59Yeah, it's good to have you. Vince, I guess it's welcome back for you, right?
- 3:02Yeah, I was on the show a while ago. Big listener, love the show. Yeah, I came here a long time ago to
- 3:09discuss one of the game theoretic libraries I work on. So yeah, thanks for having me again.
- 3:14Yeah, you bet. I love game theory. It's amazing. We'll touch on that a little bit. We're going to
- 3:19do kind of a survey of a bunch of different areas of applied math and how Python and compare that with
- 3:28how R might solve those problems, some of the libraries involved, some of the techniques involved.
- 3:33So lots of fun things. I'm looking forward to diving into them with you.
- 3:36Awesome. Awesome.
- 3:37Yeah. Awesome.
- 3:38But before we do, maybe we'll kick it off with Grant. You're new. Tell people quickly
- 3:42about how you got into programming, Python, math. How do you end up here on this show?
- 3:46So I'm a lecturer at Cardiff University in the School of Mathematics. So I learned to program
- 3:52when I was doing my PhD. Vince here was actually my PhD supervisor. So I essentially learned
- 3:58programming from Vince during that time. Nice.
- 4:01Yeah. And during my PhD, I sort of realized or I learned that everything that we'd been able
- 4:09to learn during my like master's and stuff, it was all completely doable in open source software.
- 4:15And that's kind of where I focused my PhD on then. I sort of, one of my main projects during my PhD
- 4:21was building a library to be able to do some of this stuff. And then, yeah, I passed then my PhD.
- 4:26What general area was your PhD in? I know, Matt, but what specifically?
- 4:33Discretive end simulation was where I specialized during my PhD. But like in conjunction with
- 4:38that, some of the other techniques, stuff like Markov chains and curing theory, which are sort
- 4:43of different ways of solving the same sort of problem. And that's where I sort of specialized
- 4:47in.
- 4:47Fun.
- 4:47Yeah. Very, very cool.
- 4:48We have a running, running joke with Garrett that one of his sub topics in his PhD that he became
- 4:54hyper specialized in as PhDs go was, is deadlock. And so it's, there's a tweet came up about a
- 5:00question about deadlock and all these jokes that come up. We got very excited. Well, I got very
- 5:04excited. Like Garrett, someone's joking about your work.
- 5:08That's fantastic. Vince, you've already told your story. Maybe just a quick update. What
- 5:12have you been up to in the last couple of years?
- 5:14Yes. In the last couple of years, having the pleasure of working with Garrett now,
- 5:18now that he's a colleague of mine, but otherwise continuing my work on the actual library, which
- 5:23is the library we were chatting about just now. And yeah, I'm still a mathematician at Cardiff,
- 5:28where the best part of my job is getting to teach people how to program. And that's something.
- 5:34Mathematics is such a cool subject, but in a way you're only ever a theoretical mathematician
- 5:38until you can program the stuff you're doing. Even the applied stuff is quite theoretic. And then
- 5:43it's once you can code these things that are so powerful, it really kind of releases the magic
- 5:49of mathematics for want of a less cringy type of way of saying it. So that's kind of what I really
- 5:54enjoy doing and what I keep doing. Kind of what we're going to be talking about today.
- 5:58Fantastic. Yeah, absolutely. We're going to touch on a bunch of different manifestations of that.
- 6:03Cool. I want to put out a quick disclaimer. We're going to be talking about math things,
- 6:08obviously Python things as well on the Python show here. The disclaimer is I have some degrees in math,
- 6:16but I have not done anything with them for 20 years. And therefore I know just enough to ask
- 6:21bad questions and make poor assumptions. So you all are going to have to keep me on track and just tell
- 6:26me, no, no, no, Michael, you were totally misremembering that from your courses 20 years ago.
- 6:31The real problem is we might just be on just the other side of that boundary where we could
- 6:36confidently give you bad answers. That's the...
- 6:38Perfect.
- 6:40Asking bad questions is fine.
- 6:42If you say it confidently, I'm sure it's going to be...
- 6:43Yeah, exactly. Confidently giving bad answers is the problem.
- 6:45Yeah, sure. All right, cool. Well, let's kick this off by just talking about what is applied mathematics.
- 6:54Because one of the final courses I took, it very much confused me, both in the content and just purely in its title.
- 7:02This was a course at UCSD in the PhD program there. The course was titled Applied Abstract Algebra.
- 7:09Right.
- 7:09I'm like, well, is it abstract or is it applied? Because I really don't... I just... So let's just start out with...
- 7:18We're going to be talking about solving applied math problems. Like what the heck is applied math versus
- 7:22like what I might do in a calculus class where I'm solving a bunch of like formulaic type of problems
- 7:28versus real analysis where I'm chaining theories to derive new ideas or maybe it's numerical analysis
- 7:35or stats. Like what... Where are we in the math world?
- 7:38Yeah. I think applied mathematics is an interesting kind of like term because in a way it's become a...
- 7:44It's become destroyed from its meaning in a lot of cases in that there's a whole area of applied
- 7:49mathematics as a subfield of mathematics. That's not necessarily applied in any realistic sense.
- 7:56I don't know what you think, Gerd.
- 7:58Yeah, yeah. So I think traditionally what applied mathematics was when I was doing my undergrad
- 8:02was these sort of physics models where they assume no gravity and they assume no friction
- 8:08and stuff like that, which doesn't seem very realistic to me at all.
- 8:13Yeah.
- 8:13Whereas when me and Vince have been talking about applied mathematics, sometimes that goes
- 8:18under another name called operational research or operations research. But we call it applied
- 8:23mathematics because we're applying various techniques in mathematics to a situation, a real situation.
- 8:30Right.
- 8:30I do think not necessarily by definition, but just in general, different techniques that apply
- 8:35to the more physics-y problems to the more management-style problems maybe that is there.
- 8:40But not by definition. It doesn't have to be like that. It's just that's what people find useful.
- 8:44Yeah. In a way, a lot of these labels in terms of the mathematical subfields and things are not terribly
- 8:51helpful because they create barriers between these fields. This problem I studied in my PhD where
- 8:59it's in pure enumerative combinatorics trying to count these types of matrices. Really a problem
- 9:05actually because of all other series of conversations. And the most elegant proof that came for this
- 9:10conjecture came from statistical mechanics, whatever that means, but it's a field of mathematical
- 9:17physics. And it's where all these boundaries from fields not always are helpful, whereas really the
- 9:23techniques are the helpful ones and knowing when to apply them. The definition that we would use for
- 9:30the purpose of what we're talking about today in terms of applied mathematics are just without
- 9:34necessarily going to an incredibly high level of mathematics where you're talking about the stuff
- 9:38that they do at CERN that is certainly applied. There's some very low hanging fruit. I don't know
- 9:43if that's the right word. Low hanging fruit of where mathematics can very much-
- 9:46Like day to day problems.
- 9:47Yeah.
- 9:48Exactly. Day to day. And it's where you take these ideas of, you know, in high school where you're told,
- 9:53oh, matrices are important because computers can do mathematics really quickly with them, but you
- 9:58don't do it with a computer. So, you know, who cares, right? But actually with a matrix, you can really apply these things.
- 10:03Yeah. They tell you it's important for computers and then you, yeah, then you proceed to do it by hand for the next two weeks. Yeah.
- 10:08Exactly. Exactly. Two weeks if you're lucky. Yeah.
- 10:11I wish there was some value to that, but yeah, exactly. You're like, well, I could tell you whether this matrix is singular or not, but I have no idea why I would do that. Right? So this is sort of the next step. Like, well, what would you, if you had that knowledge, that kind of knowledge, what would you do with it? Like what kind of problems could you answer? And some of the examples that you all cover in this book that we're going to highlight a little bit are things.
- 10:33Like if you have two businesses that are competing, what choices might they make? Or if no, I know this is extremely theoretical and it's never going to happen, but what if there was like a pandemic and there were people who were sick?
- 10:47Probably not that funny, but yes.
- 10:48We needed to make weird trade-offs about society. Like, should we shut everybody in a basement? Should we make them behave in different ways? What's the cost versus benefit analysis? And those kinds of things, right?
- 11:01These things that without needing too much high-level mathematics, you can describe them mathematically relatively simply. And then just with a little bit of code, you can really do cool stuff with it. Just doesn't take much code, you know, and that's, that's where Python really comes in.
- 11:17Yeah, for sure. One of the things that we'll see throughout here is there's a bunch of different examples across these different areas of math and these different types of problems in different libraries that apply to solving them.
- 11:27But the thing that's cool is every one of those solutions fits within a couple of pages on the long ones, right?
- 11:35For Jupyter Notebooks that have the solutions, plus have some of the output of the answer, right?
- 11:39Yeah, yeah, yeah.
- 11:40It's not a ton of code, is it?
- 11:42No, no, exactly. And that's, this kind of touches on something else that we were going to talk about is the idea that a lot of the time when these things are taught, they're taught with specific pieces of software, mostly commercial pieces of software.
- 11:58Yeah, yeah.
- 12:27Yeah.
- 12:28Yeah.
- 12:29Yeah.
- 12:30Yeah.
- 12:30Yeah.
- 12:30Yeah.
- 12:31It's, I also think it demystifies things a little bit because if what you do is you go to some expensive, polished piece of software like Maple or something, and you can say, you say, well, I could ask this expensive, complex, huge piece of software a question and it can magically give me the answer.
- 12:50Yeah.
- 12:51Yeah.
- 12:51It's great that you get the answer. And it's great that you know you have this very fancy tool, but it doesn't necessarily reveal a ton of understanding because of it, right?
- 12:58An idea that's beginning to form in my head. I was just saying this to Gary and I just haven't fully formed. I think there's a blog post that no one's going to read that I want to write one day about, you know, the ethics of it, about teaching these fancy commercial software. It's why these great companies give out these educational software is that they immediately have lots of users of the software that don't know how to use anything else. And I wonder if ethically as educators, if that's okay.
- 13:27I think we should make more of an effort to separate the concept from the software. And I was kind of like saying, like, I don't think we should teach any commercial software. And Darren, you made a good point when we were chatting.
- 13:38I don't really have a problem with teaching a particular topic through commercial software, as long as we teach it in a separated way so that you know, once you've formulated the concepts and the ideas mathematically, you can use whatever software you want. In the classroom, we happen to have this expensive license.
- 13:56So we're going to have this. But outside of the classroom, there are other things you can use.
- 14:00Yeah. Well, I think there's a couple aspects here. One, Vince, you spoke about the ethics of it. Is it the right thing to do to basically reinforce this loop?
- 14:08Exactly. Exactly.
- 14:09Exactly.
- 14:09That entrenches some of these. The other part is, if you're in the UK, or if you're in the US, and you say to your student, probably especially if you're in the US, they're used to getting paid so much. I just paid for both my daughters to go through college. So I'm aware that here you pay a lot for the actual tuition. But many places you'll say to students, what is it in the UK? Is there, how is college, what's the affordability? I know in Germany and other places, but don't know it that well there.
- 14:37It's a touchy subject in that tuition fees have just come in.
- 14:42And so costs of universities here are equivalent, not far off to in-state tuition in public universities in the United States.
- 14:52I think they're not far off.
- 14:54But then we get to charge, I'm saying we, very, very not talking about me, but we get to charge whatever we want to a certain extent to people from the European Union.
- 15:05And then even more to people from outside of that.
- 15:07Actually, I don't even know if that's true about the European Union because of recent events anymore.
- 15:11Yeah.
- 15:12But yeah.
- 15:13So yeah, there's a cost.
- 15:14Sure.
- 15:15Okay.
- 15:15So going back though, my point about the ethics was it's one thing to be in the US or places in Europe where we have a decent amount of money.
- 15:24It's another to say to somebody, you have to pay $500 for this software to learn the subject, right?
- 15:31Where $500 US might be the yearly income.
- 15:34For an employed person and their student.
- 15:36It seems like there's a lot of good would be done by building up maybe the missing gaps that force or encourage people to go to this commercial software.
- 15:45Building that up rather in the form of SciPy libraries and the Python data science stack in general.
- 15:54Absolutely.
- 15:55So that it's free, open source and all those things.
- 15:57I think that would apply for all subjects.
- 15:59I think really close to what we're talking about here is with mathematics, I think it's really frustrating because maybe I'm thinking too purely now.
- 16:09And I mean pure of heart, not pure mathematics.
- 16:12In terms of like mathematics is just such a clean and minimalistic subject.
- 16:16You know, you need a pen and a paper to do it.
- 16:18And if all of a sudden we're teaching people to use a pen and paper to do mathematics and saying like, oh, but you can only do it with a pen made by a BIC.
- 16:26And don't worry, BIC has given us all this free pen.
- 16:30The Mongron pen is the only one.
- 16:30Exactly.
- 16:31Right.
- 16:32And then once you graduate, if you want to write down this idea again, you have to use a BIC pen, but you have to pay for it yourself.
- 16:38And I really do think mathematics, the evolution of mathematics and a lot of science, I would argue, is into computing, right, is into getting computers to do it.
- 16:48And that extension of using the pen now is to use code.
- 16:51And yeah, it's...
- 16:52For me, at least, I think one of the important things is that separation of mathematical concepts to software.
- 16:59Because it's a lot less of a problem, but there's still a problem going.
- 17:03The only way you can do this is by using free open software.
- 17:06There are some places, unfortunately, that are not allowed to use open software because they think there's security problems and stuff.
- 17:12So if you've only taught open software, then certain, like the NHS, for example, I know they discourage using open software.
- 17:18So maybe you then think, oh, I can't do this maths thing anymore.
- 17:21But if you've separated the concept from the software, at least you know the concept and you know you've got choices.
- 17:27Yeah, absolutely.
- 17:28Yeah.
- 17:28I think that's very true.
- 17:30Separating the concept from the software is key where possible.
- 17:33And I think perhaps we don't always do a good job of that.
- 17:36And here I am speaking as an industry.
- 17:38I think sometimes we often...
- 17:39I've been to conversations where people have said, I need to use MATLAB.
- 17:44Can you help me with MATLAB?
- 17:45But it turned out they wanted to know how to numerically solve a differential equation.
- 17:48They didn't want to do MATLAB.
- 17:49They just wanted to solve a numeric equation.
- 17:51They just did not know that that's what they were doing.
- 17:55This portion of Talk Python To Me is brought to you by the Compiler Podcast from Red Hat.
- 18:01Just like you, I'm a big fan of podcasts.
- 18:04And I'm happy to share a new one from a highly respected and open source company.
- 18:08Compiler, an original podcast from Red Hat.
- 18:12With more and more of us working from home, it's important to keep our human connection with technology.
- 18:17With Compiler, you'll do just that.
- 18:19The Compiler Podcast unravels industry topics, trends, and things you've always wanted to know about tech
- 18:25through interviews with people who know it best.
- 18:27These conversations include answering big questions like, what is technical debt?
- 18:31What are hiring managers actually looking for?
- 18:34And do you have to know how to code to get started in open source?
- 18:37I was a guest on Red Hat's previous podcast, Command Line Heroes,
- 18:41and Compiler follows along in that excellent and polished style we came to expect from that show.
- 18:47I just listened to episode 12 of Compiler.
- 18:49How should we handle failure?
- 18:51I really valued their conversation about making space for developers to fail
- 18:55so that they can learn and grow without fear of making mistakes or taking down the production website.
- 19:01It's a conversation we can all relate to, I'm sure.
- 19:03Listen to an episode of Compiler by visiting talkpython.fm/compiler.
- 19:08The link is in your podcast player's show notes.
- 19:10You can listen to Compiler on Apple Podcasts, Overcast, Spotify, Pocket Cast,
- 19:15or anywhere you listen to your podcasts.
- 19:17And yes, of course, you could subscribe by just searching for it in your podcast player,
- 19:21but do so by following talkpython.fm/compiler so that they know that you came from Talk Python To Me.
- 19:27My thanks to the Compiler Podcast for keeping this podcast going strong.
- 19:34We can dive into the applied math aspects, but I think one other final thing on this is I feel like professors,
- 19:42especially as they get older, they've taught a certain way with a certain set of tools for 20 years.
- 19:48And you know what?
- 19:49That course they wrote, they already have the materials and exercises and all of that.
- 19:54And the idea of saying, well, we're going to now throw out this and like grab some new open source library.
- 19:59I mean, there's 350,000 libraries on PyPI and they're always changing and turning and something new is coming along.
- 20:06And it's maybe a lot to ask, but also maybe not too much to ask to say, look, you should keep up with these things.
- 20:13And if there's a new way to present it to your students, not because even some of the ethics stuff,
- 20:18but you might be doing a disservice to your student to say, look, the only way that you can solve these problems is with say Fortran,
- 20:24or the only way you can do it is with a $2,000 toolbox extension to MATLAB.
- 20:28That's the way that you have to go to solve this.
- 20:30And here's this, you know, super well-respected professor telling you that's how you do it.
- 20:34Well, that's not actually how you do it.
- 20:35That's how they've done it for 20 years.
- 20:37And so there's a lot of inertia there, right?
- 20:40I'm really near what being a lecturer, so maybe I'm being really naive here, but it is an effort to keep up with all this stuff.
- 20:47But that's our job.
- 20:48Our job is to keep up with the latest maths.
- 20:51Anyway, if I was still using, if in 30 years time, I was still using the same maths as I'm using today,
- 20:56I wouldn't be doing my job properly.
- 20:58So why would, why is the same true with software?
- 21:00I think it actually frankly comes back to ethics in that, you know, it's, it's unethical to not make the effort to update your training.
- 21:08And if we were talking about doctors and surgeons, they do need to learn new things as the science evolves.
- 21:13And I think probably with, with lecturers, professors, higher education, it, it comes back to that dichotomy between research and teaching and how teaching is viewed.
- 21:23So, but yes, absolutely.
- 21:25I think, you know, in a way I would be disappointed if at the end of my career I'm still teaching Python.
- 21:30In a way I'll say, oh, by that.
- 21:32Not 2020 Python, but, you know, 2050 Python or whatever it is, right?
- 21:37Absolutely.
- 21:37Yeah, exactly.
- 21:38Oh, Pythons are, you know, I started teaching Python 2.
- 21:40Or Python Plus Plus.
- 21:41And then I had to figure out how to teach both.
- 21:43Yeah.
- 21:43And he's having it.
- 21:44Exactly.
- 21:45Yeah, yeah.
- 21:46So you, sorry, I cut you off.
- 21:47So you started teaching Python 2 and then now you've moved on.
- 21:50And then I had to figure out how to deal with Python 2 and 3 and now I just keep 3 and yeah.
- 21:55Yeah, that's, I can't believe that transition took so long, but well, there it is.
- 21:59Let's dive into some of the problems and we're going to, more specifically, I'm going to take
- 22:04this book that you all created and use it to sort of guide our exploration of both some of
- 22:10these problems, how we might solve them with Python and some of the libraries that make it
- 22:14possible.
- 22:14I guess one of the things that struck me about that journey is that there's not that
- 22:18many external packages that are required.
- 22:21It's not like, well, this one takes 10 to solve this problem.
- 22:24This one takes these complex, these five, if you put them together just right, you get the
- 22:28answer.
- 22:28So that'll be fun.
- 22:29But, you know, tell us a bit about this book, Applied Mathematics with Open Source Software.
- 22:34So publisher, this is an academic publisher, which amongst other things means the book is really
- 22:39too expensive, but they often just send out emails to people saying, you know, hey, could
- 22:43you write a book?
- 22:44It's not necessarily a source of flattery, but, you know, got one of these emails and
- 22:49Geraint actually had just given a talk at Tycon UK.
- 22:53I don't know if you want to say a little bit about the talk you gave.
- 22:55Yeah.
- 22:56It was very much a precursor to this book where I had given an introduction to the field of
- 23:01operational research, which is how we label this certain type of applied mathematics and
- 23:07all the different problems that could occur.
- 23:09And I think the title of the talk was, there's a library for that because every sort of problem
- 23:14that we could come up with, you could pip install a library and in a function or two solve the
- 23:18problem, which was a neat little...
- 23:20Yeah.
- 23:20Oh, there it is.
- 23:21There's a neat little...
- 23:22That's it.
- 23:22Is it?
- 23:23Yeah.
- 23:23Yeah.
- 23:23Yeah.
- 23:24I'll link to it.
- 23:25Yeah.
- 23:25If I can just interrupt, the call for proposals for Tycon UK closes on Saturday.
- 23:29So if you're thinking of talking, please submit a talk.
- 23:33So yeah.
- 23:33And it was just really neat that we had these, like, what we call standard problems.
- 23:38It was essentially our postgraduate MSC course that we teach.
- 23:41But instead of teaching the maths, there was one or two Python functions that solved it for
- 23:46you.
- 23:46And then, yeah, that eventually evolved into this book where instead of each little topic
- 23:52being a couple of functions, we filled out chapters on some of the theory and, again, tried to
- 23:57separate the maths and the programming, emphasizing that by introducing another language, which was
- 24:02R, to show that you can do it in two different ways and that the software is independent of the
- 24:06problem.
- 24:06I think you and I have described it because every now and then, as we were writing the
- 24:09book, we kind of stop and go, wait, who's the book for?
- 24:12You know, and as we were like making decisions about how exactly to do something, we're like,
- 24:16wait, who's the book for?
- 24:16And I won't necessarily, well, maybe we should talk about that.
- 24:19But I think we've kind of written a book that's meant to be useful to people wanting to get started
- 24:25either with the mathematical field problem or with how to actually do it with the code.
- 24:32And so every chapter has got the same kind of structure that describes a problem,
- 24:36then it describes the basics ideas behind the theory of the problem or the mathematical tools,
- 24:42the theory behind the mathematical tools.
- 24:43But again, not going into too much depth, kind of what I said before about you don't need to
- 24:47understand all of Newton and Leibniz's calculus to be able to kind of predict the outcome of a
- 24:54pandemic.
- 24:55And then it just solves the problem.
- 24:57The original problem, it solves it in two separate ways, using R and Python.
- 25:01And the final kind of section in every chapter is pointing at a bunch of literature on it,
- 25:06which we thought would be useful.
- 25:07Yeah.
- 25:08And we're more broadly, you might be able to, these types of problems appear and what you
- 25:13might be able to do with it.
- 25:14Yeah.
- 25:14But the really cool stuff with the publisher is that we had an ongoing kind of conversation
- 25:17before the start.
- 25:18Garrett and I were both like, well, the book has to be open.
- 25:22They've agreed like, oh, there's not a PDF floating around online of the book,
- 25:25but all the source files are there.
- 25:27So all the late deck files are there.
- 25:29There's all the Jupyter notebooks are there with the code.
- 25:31We haven't quite gotten all the R markdown files up yet, but they are theoretically all
- 25:35there.
- 25:36And so the book is very open, which we're happy about.
- 25:40Yeah.
- 25:40That's great.
- 25:41It is very shiny new.
- 25:43It still has that new book smell.
- 25:44It was released just almost exactly a month ago, right?
- 25:48That's right.
- 25:49That's right.
- 25:49Yeah.
- 25:50Keep on saying I've got to have Garant over to celebrate, but we don't get around to doing
- 25:54that.
- 25:54I had to sign a copy for my nun.
- 25:57Oh, nice.
- 25:59That's very sweet.
- 26:00That's so nice.
- 26:01All right.
- 26:02Now, before we dive into the various problems in the Python side, while we're still kind of
- 26:06talking a little bit high level, this is one of the interesting aspects here is the Python
- 26:10and R aspect.
- 26:12So when you go through each chapter, which is, I think I agree with you that it's pretty approachable,
- 26:18even if you don't have a, you don't have to have like a master's in math or specialize
- 26:22in that area for it to make sense.
- 26:23It doesn't have, if you don't really want to see a ton of formulas.
- 26:26Yeah.
- 26:26It's not super intense.
- 26:27I think that's our first official review, Michael.
- 26:29Pretty approachable.
- 26:30It's fantastic to share.
- 26:31Yeah.
- 26:34Well, like I said, my math, while I said a ton of it is highly rusted, it was pretty approachable
- 26:40for me.
- 26:41So there's that.
- 26:41But maybe just talk about putting R and Python side by side for solving a set of different
- 26:47problems.
- 26:47What are some of the takeaways either of you got from that?
- 26:50One thing we wanted to do here, because we would, well, I would certainly.
- 26:53describe myself as a, as a Python person, non-R person.
- 26:57I know R, I write R, I've written a book in R, but I would certainly describe myself as
- 27:01a Python person in that.
- 27:02If you're going to sit down and write something, you would pick Python first.
- 27:05I would pick Python.
- 27:06Exactly.
- 27:07But also, you know, I'm embedded in the Python community.
- 27:10I listen to some good Python podcasts.
- 27:14I'm a Python person and I can look at some Python code and the joy is that looks very Pythonic,
- 27:20right?
- 27:20I can, I can, I can tell you that.
- 27:23And so we were kind of aware that we didn't want to translate the Python to R when we were
- 27:28writing this.
- 27:29We wanted to, you know, write this as close to our people as, as we could.
- 27:34I don't know if we managed that, but that was something as well that we were aware of.
- 27:38It's not just translating languages.
- 27:40In Python, yeah, in Python, we have the word Pythonic for idiomatic Python.
- 27:46Do you all know, is there a word for that in R or is it just idiomatic R?
- 27:50I don't know.
- 27:52Yeah.
- 27:52I don't either.
- 27:53Yeah.
- 27:54I think you're right.
- 27:54You were going to say something.
- 27:55Jump in here.
- 27:56So I was going to say, like, as we were writing the book, we noticed that there were certain
- 28:00problems, which the R and the Python lined up exactly, not from design, just from, if we
- 28:06were going to approach these independently, it is pretty much exactly the same.
- 28:10way to solve it.
- 28:11There were some problems where we had to reformulate the mathematics because the way
- 28:17to do it in R was so different to the way you do it in Python.
- 28:22That doesn't mean the math's changed.
- 28:23We just had to reformulate it, re-communicate it so that we could write it down in R.
- 28:28And then there were some problems, again, where we had to use different mathematics to
- 28:32solve it in Python and R because of the availability of libraries and stuff.
- 28:36I thought that was really, really neat.
- 28:37And I think that emphasizes, again, the separation of concept to software because sometimes you
- 28:44did have to do very different things in different softwares.
- 28:46My favorite chapter on this is the one that is your specialty, Darren, the discrete event simulation
- 28:53chapter, where I forget the name of the two theoretic ideas about discrete event simulation.
- 28:59Process-based and what's the other one?
- 29:02Yeah, so there's process-based and there's the event scheduling approach.
- 29:07There's two different ways of approaching discrete event simulation.
- 29:10And the standard library in R to do it is process-based.
- 29:15And I don't want to call it the way to do it in Python, but the way we've said in Python
- 29:20to do it is by using the Q library, CIW library.
- 29:24The only reason Gerard doesn't want to say it's the way to do it in Python is because it's
- 29:27using his library, the library that he's maintained around.
- 29:30Yeah, nice.
- 29:33Both those libraries, I'm pretty sure that underneath, well, I know how Q works underneath, but the
- 29:39Simmer, which is the R version, I'm pretty sure underneath they work very, very similarly.
- 29:44There's not many ways you could do different ways of discrete event simulation, but the way
- 29:48you formulate the problem is very different.
- 29:51And going through that in the book and going in Python, you have to take like an overhead
- 29:57worldview where you look at the system, whereas in R, you have to take a sort of, you have to
- 30:03put yourself in the mind of the customer and go, what is the customer doing right now, rather
- 30:09than from a systems point of view, in order to formulate the problem before you could just
- 30:13then go and solve it.
- 30:14I just thought it was very, very interesting that the way to do it in each language was
- 30:19so different.
- 30:20And yet probably underneath, it's doing exactly the same thing.
- 30:22You get the same answers out.
- 30:23You just got to formulate it in a different way.
- 30:25Yeah.
- 30:25I think that's such a nice example where diversity, and I'm using diversity from the way that languages
- 30:30do things.
- 30:31I think that's the best chapter in the book, frankly.
- 30:33I think that's the best chapter in the book because you not only do things differently
- 30:38from a programming point of view, but because you do things differently from a programming
- 30:41point of view, the theoretic discussion allows you to kind of, yeah, give a really good
- 30:46understanding of these two ways of doing it.
- 30:48Yeah.
- 30:49Yeah.
- 30:49Something else that's kind of worth mentioning about the Python in our bit.
- 30:52I don't know if this is a terrible address, but I like tests.
- 30:55I don't like trusting in any code.
- 30:57I like writing tests all the time.
- 30:59And we came to this media thing that we wanted the book to be tested.
- 31:02We wanted to know the code was correct in the book, but we wanted to have these two different
- 31:05languages.
- 31:06And we didn't want to kind of use the standard doc test notation for the Python.
- 31:09And then we wanted to find something that would work for the R, et cetera.
- 31:12So we actually wrote a little language agnostic doc tester that basically runs through and tests
- 31:18all the code in the book for us.
- 31:20And theoretically, when we write the second edition and we add Julia as well, it will be up
- 31:24to handle it.
- 31:24Yeah, I guess Julia is another option that could have possibly shown up in here.
- 31:29Pretty interesting.
- 31:30I guess it's worth pulling this up.
- 31:31It's probably worth pulling up the Stack Overflow friends and putting those in there.
- 31:38Yeah.
- 31:38Right.
- 31:38So we have R.
- 31:40We've got, I don't know where these all lie right now, but I would imagine that the graph
- 31:46looks a little bit different across these.
- 31:49Just for people listening, I would say R is certainly growing.
- 31:53It's actually growing pretty healthily compared to many, many programming languages.
- 31:57And it's not going crazy, but it's going across.
- 32:00And you've got Python, which if anyone's looked in the last couple of years, it's just done
- 32:05insane stuff in terms of popularity over there.
- 32:08So there's that.
- 32:09And then Julia is, it's, I don't know, I can't really read it.
- 32:12It's, you know, like point.
- 32:13Not quite the same scale.
- 32:150, 1% versus say like 2% for Julia, for R, excuse me.
- 32:21And then for 16% for Python.
- 32:23There is something to be considered about choosing not just a language because the language has
- 32:28a cool way of doing async or its generators are beautiful, but choosing a language for its
- 32:33ecosystem as well.
- 32:34Yeah.
- 32:34And that's where it touches on this here, right?
- 32:36But also for the community that's already there, I think.
- 32:40Yeah.
- 32:40At least in the area of mathematics that me and Vincent are in, I think R and Python are quite
- 32:47prevalent, but they're also used in different.
- 32:49Maybe their peers there, right?
- 32:50Yeah.
- 32:50Yeah.
- 32:51A little closer than this would show.
- 32:53I think they're also used in different ways.
- 32:54Would you agree, Vince?
- 32:55I would say Python's very, because of PyPy, things like out of the box, there's one library
- 33:01to do this and it's their way to do it.
- 33:04Whereas with R, people tend to write their own stuff and then upload it to Cran.
- 33:08Yeah.
- 33:09So you might get lots and lots of different ways of doing the same thing, but each one might
- 33:14specialize slightly in a different way.
- 33:16Whereas with Python, I feel like there's one library that does it really, really well.
- 33:21I think people just use the ecosystems in different ways.
- 33:24This portion of Talk Python To Me is brought to you by the Python at Scale Summit.
- 33:30The Python at Scale Summit is a conference to highlight innovative big data solutions for
- 33:35Python developers and enterprises.
- 33:37You'll learn about trends in the Python big data ecosystem, share stories about implementing
- 33:42solutions, find out about new innovations, and connect with other data scientists using
- 33:47Python.
- 33:47The Python at Scale Summit will be a hybrid conference with talks, workshops, and training.
- 33:53Of course, there will be networking and social events to connect with other Python professionals
- 33:57too.
- 33:58Come hear speakers like Matt Rockland from Coiled, Brian Granger from AWS, and many others from
- 34:04amazing organizations such as NASA, Capital One, and BCG.
- 34:08Get back together with your peers and learn how they're scaling their computation and data analysis
- 34:13using Python and the data science stack.
- 34:16Register at talkpython.fm/python dash at dash scale.
- 34:21When you visit the link, be sure to use the code TALKPYTHON, all caps, to get 15% off your
- 34:28tickets.
- 34:28That's code TALKPYTHON at talkpython.fm/python at scale.
- 34:32The links in your podcast player's show notes.
- 34:34Thanks to the Summit for supporting the podcast.
- 34:39Yeah, both those two things are often talked as strengths of either library, right?
- 34:43The fact that Python has that one way to do things and the set of different ways to do
- 34:47string formatting conversation comes up.
- 34:49But then the fact that R is kind of like closer to the science.
- 34:54I don't know if that's even accurate, but that's the feeling, I guess, is also a strength, right?
- 34:59Yeah.
- 34:59The reason there's lots and lots of libraries to do the same thing is because they've each
- 35:02specialized in something which a new academic has just written a paper on.
- 35:06And that's why there's lots of different ways of doing it.
- 35:08Yeah.
- 35:08All right.
- 35:09Sure.
- 35:09And maybe, you know, like out in the audience, the ninja says R is really powerful when it
- 35:14comes to things like analytics and so on.
- 35:16Right.
- 35:17So maybe there's certain areas where, you know, there's the libraries you can pick that
- 35:21are definitely better.
- 35:22Okay.
- 35:22Now we talked about the book.
- 35:24The book also, as you pointed out, has an open version where you can find it on GitHub,
- 35:30which obviously we'll link to.
- 35:32And in here for each one of these, you've got some examples, which are basically the, at least
- 35:38for the Python side, the Jupyter Notebook examples here.
- 35:42So I thought maybe we could sort of talk through a little bit.
- 35:45What is the problem?
- 35:47And then maybe really first quick, quickly introduce what this area is.
- 35:52Cool.
- 35:52And then what we can then talk about the problem, the example problem you put out there and some
- 35:57of the libraries and techniques there.
- 35:58Sure.
- 35:58So the chapter two, which you're looking at right there, you say is about a mathematical
- 36:06idea called, a mathematical concept called the Markov chain.
- 36:09So it's this probability model that you loosely go that you're, as the system go,
- 36:16model changes over time.
- 36:18The system is in a particular state.
- 36:20And then you go with a given probability of being in that state to another state.
- 36:24You can go around like that.
- 36:26That's not the best explanation I've ever given.
- 36:28I've explained that many times.
- 36:29That's probably one of my worst explanations.
- 36:32But market change can be used to model queues.
- 36:34And there's a whole field of mathematics called queuing theory.
- 36:37And that is often used as a very applied problem.
- 36:41And so the problem we got here is imagine you've got a barber.
- 36:44The barber has kind of two decisions, how many chairs they have to cut hair in and how many
- 36:50chairs they have to keep people waiting for a chair.
- 36:53And obviously that has an impact on the queue, right?
- 36:56Of how long people have to wait to get their hair cut.
- 36:58And you can use Markov chains to build up a model and find the probability of having to wait
- 37:03relatively simply.
- 37:05I know, Garen, if you want to clean up what I just said.
- 37:06No, yeah.
- 37:09So I think the model then would be the second state and the probabilities of going between
- 37:15each state from the state unit.
- 37:16And that can be written as a matrix.
- 37:19And the neat thing then is there's loads and loads of linear algebra techniques, which at
- 37:24this point you don't really need to know about.
- 37:25But there are linear algebra techniques, which stuff like number can just do for you, which
- 37:30if you know which techniques to use, you know how to interpret that as a real life
- 37:35interpretation.
- 37:36So for example, there's one certain set of equations you can solve using our Markov chain,
- 37:41sorry, using our matrix, which will give you the long run probabilities of being in each
- 37:46state.
- 37:46There's another certain linear algebraic technique, which will give you something else.
- 37:50And that's what this is.
- 37:52Yeah, nice.
- 37:53Yeah, the problem is essentially comes down to solving a matrix equation, which you could
- 37:57write down and understand with basic mathematical knowledge.
- 38:01And then that can be solved.
- 38:02This goes back to what you told in high school, that matrices are great because computers can do
- 38:05them fast.
- 38:06But then you never actually get to do that.
- 38:07You just write down equations.
- 38:08But it's just a call to NumPies, the knowledge library.
- 38:12You can just solve it immediately for you.
- 38:14It's amazing.
- 38:14Yeah.
- 38:15So the problem here to make this applied or more operational, I guess, that you all put
- 38:20out there says you have a barbershop and the shop notices that there's a lot of customers
- 38:25who are, they come and the shop is full and the waiting room is full and people just leave.
- 38:30And I, you know, since COVID, I've just decided I'm cutting my own hair.
- 38:33I can't, it took too long to find a barber or anything that worked.
- 38:37And then after that, I kind of figured it out.
- 38:38But there used to be this place I would go to and boy, did it need this problem.
- 38:41It would be, you would go there and be like an hour and a half wait.
- 38:45And, you know, you just, all the time and you never knew.
- 38:48But so they would solve it by giving away free beer to people while they wait, which was nice.
- 38:53But this one wants to solve it more in a more formal business way where they want to have
- 38:58people just wait less.
- 38:59So it says you have two barber chairs, there's room for four people in the waiting room.
- 39:03There's about 10 customers an hour and it takes about 15 minutes to serve a customer.
- 39:08How can we minimize or how do we change things so that we don't have customers leaving because
- 39:14they come in, see a full waiting room and take off, right?
- 39:16Instead of knocking down a wall and building a bigger waiting room and, or spending a lot
- 39:22of money on an extra barber chair and just seeing the effect and maybe five years later trying
- 39:26the other way, you can just mathematically model this.
- 39:29And this is a good example of, I think what we described as applied mathematics is that you
- 39:33can answer these cool questions.
- 39:35So you could say, well, maybe we need a bigger waiting room.
- 39:38Or maybe we need more barber chairs or something like that.
- 39:41Right.
- 39:41And then you can make that trade off.
- 39:42Yeah.
- 39:43So let me find the, this is the numpy, numpy dot lin alg magic.
- 39:49And so basically you set it up so that you set up all these scenarios in these constraints
- 39:53and then you just say numpy solve it, right?
- 39:56That's pretty much it.
- 39:57Yeah.
- 39:58And mathematically you're, you write down this matrix a and another vector b and you're solving
- 40:03the equation ax equals b.
- 40:04Most of the code is just getting the matrix set up and the b set up.
- 40:09Actually, most of the code is the doc strings.
- 40:12And then, and then, yeah, you just use the lin alg dot least squares.
- 40:15That's one of many ways you can do it.
- 40:17Least squares is actually getting an approximate solution to the linear, linear algebraic equation.
- 40:22And there's various reasons why that's a better idea than solving it directly.
- 40:25And yeah, it's just, it's basically one line.
- 40:27I think one of the neat things about this then is all that maths you sort of learn in school
- 40:33or even first year university where you're doing sort of row operations and stuff.
- 40:38That's not the mathematics that matters here.
- 40:40The mathematics that matters is what is the matrix you need to do that to?
- 40:44And once you've done it, how do you interpret the result?
- 40:46That is the mathematics.
- 40:48It's not the actual operations that you spent so long doing in first year university.
- 40:54Yeah, that is a bit ironic.
- 40:55That's such a good point, Darren, because I think what is mathematics is an interesting question, right?
- 41:00And like, is it being able to differentiate a whole bunch of quadratics really fast?
- 41:04Or is it knowing which quadratic you need to differentiate, right?
- 41:07And I would argue that it is that, you know, it's knowing what, really knowing what the problem is.
- 41:14So that, okay, then the actual specific mathematical technique, well, who cares, right?
- 41:17Sure.
- 41:18Well, events people so often say, oh, I'm never going to use that.
- 41:21I'm never going to do these things.
- 41:23I could do that with a calculator or I could do that.
- 41:25I think a lot of that might be slightly misplaced.
- 41:28I'm not going to say misplaced, but somewhat misplaced focus on some of these things, right?
- 41:33Like if you could say, well, spend a little time showing you how to differentiate,
- 41:36then we'll show you how to actually solve problems with that instead of just getting,
- 41:40you know, more and more complicated techniques that you can apply.
- 41:44Yeah.
- 41:45Integration's more of a pick and choose, right?
- 41:47I like to find which thing applies.
- 41:49But still, you know, instead of going deep, deep, deep, deep, deep into that on the first
- 41:53year stuff.
- 41:54Yeah.
- 41:55Yeah.
- 41:55You had someone on the show a little while ago called Allen Downey.
- 41:58Yeah.
- 41:59He writes a lot of really great books.
- 42:01And I remember what he said on your show was about, he likes to think of teaching these
- 42:05things in the other way that code allows you to do these things immediately.
- 42:09So instead of waiting through and waiting and having to have faith that there's going to
- 42:13be used to it.
- 42:14You can just flip that around, you know, and understand what it is.
- 42:18I think there's also a lot of that and what we should be doing.
- 42:21Yeah.
- 42:21That's a very good point.
- 42:22I totally agree.
- 42:23All right.
- 42:23Wrap this one up.
- 42:24You were able to find that it would be better to increase the number of barbers by one than
- 42:30increase the waiting room capacity by two.
- 42:32Because I think the chance of the shop being full is like 23% if you had something like
- 42:38that.
- 42:38Yeah.
- 42:38Yeah.
- 42:39Yeah.
- 42:39Versus like 8%.
- 42:41Those kinds of things.
- 42:42And those are really concrete numbers that you could go to a business and say, you know,
- 42:47you hired us to analyze these things.
- 42:49We gathered all the necessary information, like average time, you know, how much that might
- 42:54vary and those kinds of things.
- 42:55And here are your choices and here are what are the rough expected outcomes.
- 42:59Like that's really, really valuable information.
- 43:02And I am very sure that most barbershops, even chains, don't do this kind of analysis.
- 43:08Not necessarily in your algebra going on in barbershops.
- 43:10That's an interest.
- 43:11That's a bold claim.
- 43:12I know.
- 43:13And this question, so a lot of the research, Darren, that I do is within healthcare.
- 43:21So we work with hospitals solving essentially very similar problems to the one that we've
- 43:26just discussed.
- 43:26We were keen to avoid too much healthcare because that's what we do so much of.
- 43:30But yeah, this, this, if you get rid of the idea of a barbershop, you talk about a ward,
- 43:34how many beds are on the ward, how big's the party out for ambulances to wait in, et cetera,
- 43:38et cetera.
- 43:39That, that becomes very important and very powerful and not, not something you need to spend thousands
- 43:44of pounds or dollars on licenses for.
- 43:47Not, you know, the, the, not necessarily even have a huge understanding of, of the learning
- 43:52mathematics.
- 43:53It's all right there.
- 43:54It's all right there available to anyone.
- 43:55Yeah.
- 43:56But there's way more at stake in a hospital and healthcare than there is for a, of course,
- 44:02yeah.
- 44:02A haircut.
- 44:02Yeah.
- 44:03Okay.
- 44:03Let's go on to the next one.
- 44:06So the next topic is discrete events.
- 44:09So I'll find my way over to that one.
- 44:12And y'all introduce this one to discrete event simulation.
- 44:16This sounds like this might be somewhat in your wheelhouse, right?
- 44:19Yeah.
- 44:20So I think discrete event simulations probably, if you're used to programming, this is probably
- 44:25the one that probably makes the most sense because it's moving virtual things from the
- 44:30place essentially.
- 44:30So the question we're answering, we're asking here is very similar to the question we just
- 44:38answered with Markov chains.
- 44:40But sometimes things are too complicated to be able to formulate that correct matrix or
- 44:46the matrix doesn't quite work because the situation is a bit too complicated.
- 44:49But what we can do is build a virtual representation of our system.
- 44:53And by sampling random numbers, we can move virtual people around our barbershop and look at what
- 45:00would happen, right?
- 45:02And just observe, collect data, crunch that data.
- 45:05And this is what discrete event simulation is.
- 45:07It's building a virtual representation of the system, using random numbers to play that
- 45:13virtual representation system, and then collect some data about what just happened virtually.
- 45:17Okay, excellent.
- 45:18So this one, let me set the problem that you all laid out here.
- 45:20This is a bicycle repair shop.
- 45:22And there's a set of gates or actions or I guess events you might say that it flows through.
- 45:30So a bike arrives randomly at a rate of 15 bikes per hour.
- 45:36They show up and they say, hey, there's something wrong with my bike.
- 45:39And the staff member looks at it and helps them.
- 45:42That takes about three minutes.
- 45:43But it turns out about 20% of the time, the bikes don't need repair.
- 45:46There's like, did you know that there's a thing to just twist here and tighten it?
- 45:49All right, go away.
- 45:50You're fixed.
- 45:51You're cured.
- 45:52But 80% of the time, there's something wrong, flat tire, broken chain, whatever.
- 45:56And that gets put into a place where they're waiting to work on it.
- 46:00And that takes about six minutes, right?
- 46:02And then you've got to collect it back.
- 46:03The question is, I guess the difference that I see here is there's not an uncertainty of whether or not you want a haircut when you show up at a barbershop.
- 46:11There's just the amount of time and where the people are and the actions they might take if it's too full.
- 46:16But here you may show up and you may need help or you may not need help and so on, right?
- 46:21So there's, is that the difference?
- 46:22I suppose that is the difference between these two problems.
- 46:25But that's not the reason we would use simulation over Markov chains.
- 46:29In fact, the situation we're looking at here could be formulated as a Markov chain.
- 46:35The difference I see is that in this situation, you could have an infinite amount of bicycles in your bicycle shop.
- 46:43So if we were to formulate that as a Markov chain, we'd have an infinite matrix, which is not terrible to deal with, but you wouldn't be able to deal with it in the way we just did.
- 46:51Got it. Okay.
- 46:51Talking about the states that I did kind of awkwardly in the previous chapter, it's just how many people are in the shop.
- 46:58So there's three people in the shop.
- 47:00Well, there's a probability that the next thing that happens is four or the probability that the next thing that happens is two.
- 47:05So it's a very straightforward set of states that is finite, as Garen said.
- 47:11Here, there's two things to keep track of.
- 47:14There's the number of bikes being seen by, waiting to be seen by an inspector, the number of bikes waiting to be seen by the repair shop.
- 47:19And that just immediately, the fact that now you've got these two dimensions that can change, just again adds to the complexity and the fact that it's an infinite amount of them.
- 47:27Yeah.
- 47:28So the reason we would use simulation for this is because it's a more complicated situation for a variety of reasons than what we had before.
- 47:37And it would take a really, really big, if not infinite matrix to be able to solve this.
- 47:41So why would we go to that effort when we can get quick, easy answers just by virtually playing this?
- 47:47These two chapters are paired.
- 47:48And actually, there's this, all the chapters are paired in the book for the reason that they are kind of the two similar types of problems from opposite angles.
- 47:58And correct me, Garen, if you don't agree, but I think that the two opposite angles about numerical tractability, how much you can do with an exact method, which is what the previous chapter was, versus a more approximative method.
- 48:13And it's not always easy to say exactly what you should use one or the other.
- 48:17Sometimes it's absolutely clear, but sometimes it's not.
- 48:19But there's these pairs of chapters that kind of reflect that, you know, the size of the problem, for want of a better word.
- 48:25Very interesting.
- 48:25Okay, the fundamental Python bit here is the CIW, or you pronounce that Q?
- 48:31Yeah, I call that Q.
- 48:32C-I-W, Q.
- 48:35It's the Welsh word for Q.
- 48:37Q-U-E-U-E.
- 48:38It's the Welsh word for that.
- 48:39And that's why I call it the library though.
- 48:41Fantastic.
- 48:42All right.
- 48:43And so the idea is basically you state the problem in terms of the arrival rate of events, the inspection or the service distributions in terms of how those flow through there.
- 48:55The number of things that can be servicing it and the routing and so on.
- 48:59You create a network with the Q library.
- 49:02And then you could just ask it questions, right?
- 49:06You can tell it to run a simulation.
- 49:08You can run it for some amount of time, like eight seconds or so on.
- 49:13And it's interesting that it simulates it, that it doesn't exactly solve it, right?
- 49:19That's the point of simulation.
- 49:21Well, not the point, but like one of the uses of simulation is that we can quite easily simulate something that's too complicated to solve exactly or would take too long to solve exactly.
- 49:32But we can quite easily simulate it.
- 49:33The trade-off then is because assimilation is essentially streams of random numbers that we do things to, you could get extreme values.
- 49:41You could get flukes.
- 49:43So you lose accuracy, but you gain efficiency.
- 49:47Yeah.
- 49:47So the idea is you run it over and over and over again with the randomness playing out there.
- 49:52And then you just say, well, what is the most common set of outcomes look like?
- 49:56Yes, actually, I guess.
- 49:57Yeah.
- 49:57Very cool.
- 49:58So what did we learn from this one?
- 50:00That we could add an extra inspector at the front or we could add an extra repairer.
- 50:08And what was the better outcome here?
- 50:10So we were measuring was the maximum amount of time a bicycle spends in the shop.
- 50:16We wanted to get bicycles out as quick as possible.
- 50:19So if we added an extra bicycle inspector, we would reduce our time, maximum time in the shop by quite a lot.
- 50:28But if we added an extra repairer, we'd reduce it, but not quite so much.
- 50:32So we essentially found that the bottleneck was the inspection desk and not the repairing.
- 50:36How interesting.
- 50:37And I suspect, maybe this is not true, but I feel like if I was a business, knowing that would not just help me hire the right person, but I think having an inspector type of person would be easier to get.
- 50:49Right.
- 50:50You don't have to have as great of a skill set to actually be the mechanic that does the repairs.
- 50:55So that's really valuable as somebody who runs a bike shop.
- 50:59I will also throw out another statement here.
- 51:02It's probably true.
- 51:04I also suspect bike shops don't employ these techniques, but should.
- 51:07They can now.
- 51:10They can.
- 51:12Well, they can now, honestly.
- 51:14I think.
- 51:15I believe larger companies probably would.
- 51:17Stuff like supermarkets and airports probably would have a team of people behind them doing this, but smaller shops, probably not.
- 51:23Yeah.
- 51:24Gosh, I'm trying to remember the name.
- 51:25Not always, right?
- 51:26Would be a little caveat I'd say to Gary.
- 51:28We certainly know of lots of examples of big entities, companies, things that make very expensive decisions without doing these sorts of investigations.
- 51:39Yeah.
- 51:39Yeah.
- 51:40Well, you mentioned grocery stores and stuff.
- 51:42I had the folks from Kroger, which I think, if not, is the largest, one of the largest chains in the US.
- 51:49They have basically an analytics and data science subsidiary called 8451.
- 51:55They employ 200 data scientists who do R and Python.
- 51:59That's awesome.
- 52:00That's not joking around in terms of, you know, where do the bananas go and those types of things, right?
- 52:06So you're right.
- 52:07The larger companies definitely, definitely invest in that.
- 52:10It's the interesting thing about what is data science, right?
- 52:12Talking about data scientists in that, are they looking at historic data and identifying things?
- 52:18And I suspect that there's no answer to my question here.
- 52:21I suspect different data scientists do different things.
- 52:24But when you share a data science department, that doesn't necessarily mean they're doing this type of work.
- 52:29It might be.
- 52:29Absolutely.
- 52:30It might be.
- 52:30But it might also be diving into the data and understanding and observing as opposed to necessarily modeling possible.
- 52:37It could be AI.
- 52:38It could be AI and ML.
- 52:40It could be a data ETL, just bringing in data and just getting into system.
- 52:45Yeah, there's all these different aspects.
- 52:46I wonder more about the data science on when do I go from being somebody that uses, say, Python for computation to becoming a data science, right?
- 52:58When do I, would you cross the boundary from being a mathematician or a biologist to becoming a data scientist that has some understanding of biology, for example?
- 53:07I would argue it kind of goes back to what we were saying earlier about what is an applied mathematician and, you know, at what point are these labels helpful and at what point are they not, right?
- 53:14Yeah, exactly.
- 53:15Out in the audience, Fritam says, yeah, data science is such a catch-all phrase right now.
- 53:21I would agree.
- 53:21Also a buzzword.
- 53:22So if you're looking for a job, it's a good one.
- 53:24All right.
- 53:26Let's go on to another one.
- 53:28We'll get through as many of these as we can.
- 53:30And then we have time for anyway.
- 53:32So those two problem areas were paired together.
- 53:35Yeah.
- 53:35The next area that you focused on is fairly different with differential equations.
- 53:40So those two areas that we were just in is the book's got parts and it's two chapters in every part.
- 53:44And that was in the probabilistic modeling is what we'd call it.
- 53:47It's modeling these probabilistic type situations.
- 53:49And here we're in the dynamical systems section.
- 53:52And so specifically here, we're looking at a problem where differential equations can be used.
- 53:56And we wrote, we started writing this book before the world changed, before COVID happened.
- 54:03And I remember coming into our writing sessions.
- 54:07I have to say, I really enjoyed writing the book.
- 54:08Very glad to have it finished, but I enjoyed writing the book.
- 54:11And I said to Gary, Gary, do we need to change this chapter?
- 54:14Because this chapter, there's a disease going around.
- 54:17I think we call it a cold.
- 54:18Yeah.
- 54:18Everyone's caught a cold in a small community.
- 54:21There's a cost to not being able to work.
- 54:24So coined that to have a cold.
- 54:24Right?
- 54:24And there's a cost, a financial cost to not be able to work.
- 54:28Financial cost with a possible cure that would double the rate at which you get better from the cure.
- 54:35Is it worth, from the cold, pardon me, is it worth financially to get this cure was the problem.
- 54:43And yeah, we were like, should we make this about COVID?
- 54:45You know, should we just essentially all the graphs we spent so long looking at that was on the news all the time.
- 54:51You know, this is it.
- 54:51This is essentially the same thing.
- 54:53Yeah.
- 54:54Should we make it about COVID?
- 54:55And we decided not to, didn't we, Gary?
- 54:57We decided to just keep it somewhat abstract.
- 54:59But yeah, that's the problem here.
- 55:02And yeah, the model is, is a textbook for want of a better word, a textbook model that's often taught when you start learning about systems of differential equations called the SIR model.
- 55:15And the SIR model has a population in three groups, susceptible people.
- 55:21Sorry, Vince, I think you're talking about a different chapter.
- 55:23I am talking about the right chapter.
- 55:24Thank you, Gary.
- 55:26Thank you, Gary.
- 55:27Sorry, I went off on one.
- 55:28Thank you.
- 55:29That's the next chapter.
- 55:30No, no, brilliant, Gary.
- 55:31They're similar.
- 55:32Yeah, they're similar.
- 55:33Very similar.
- 55:35This one we wrote, you can write down a differential equation that dictates not a system, but just the number of people that are infected over time.
- 55:42And so you can write that down, that differential equation.
- 55:45You can get a solution for it.
- 55:46Sorry.
- 55:47Thank you, Gary.
- 55:48Thank you.
- 55:51Yeah, no worries.
- 55:52This one actually uses an interesting library that I am just fascinated with.
- 55:57It's an awesome library.
- 55:58Called SimPy, right?
- 55:59Yeah.
- 56:00Yeah.
- 56:00I just had the folks on back in May, not too long ago for this one, Andre and Aaron for this.
- 56:06And I did not expect this from Python because it's, I expected NumPy and the linear algebra type things, but not, you know, here is the integral of this solution of this differential equation.
- 56:20And here are the steps that I took to get there.
- 56:22It is so neat.
- 56:22SimPy is an incredible library that just gives you so much of what mathematics is thought to have to be commercial in that you can have all your symbolic stuff.
- 56:31So, you know, if you want to know what is X plus X, you don't need to tell the computer what value X has.
- 56:38With SimPy, the computer can just understand the concept that X is this mathematical idea.
- 56:43And it's incredible.
- 56:44And it's a fantastic, fantastic library.
- 56:47I think it was when I started teaching programming to our first year cohort, I actually taught SageMath and SageMath is built on top of SimPy.
- 56:55But at some point I decided to just teach with SimPy.
- 56:59And so that's what we use here.
- 57:00That's what we use here.
- 57:00We build up the actual numeric solution for the differential equations.
- 57:04We find the expression that if you put it into this differential equation, that would be the solution.
- 57:11We get an exact solution here.
- 57:13It's pretty wild.
- 57:13You say the way you set it up.
- 57:15I mean, everything about SimPy is wild.
- 57:17But the way you set it up here is you say, I'm going to create some symbols like time T or constant alpha or so on or initial conditions.
- 57:26And then you say, I'm going to have a function.
- 57:28You don't say what the function is.
- 57:29You say there is a function called I.
- 57:31And then what you define for the thing you're going to work with is you say, sim.equation.
- 57:37And you say, the equation is going to be given the derivative of this function of T and T.
- 57:44And then it has this expression in there.
- 57:46Negative.
- 57:46I guess that's probably the, what you're specifying here is this is the derivative, not the equation itself, which is negative alpha times I of T, right?
- 57:54This is one of those parts of SimPy that when we teach this to our first years, it allows us to help identify misunderstandings about the mathematics.
- 58:02I think programming can often help you understand mathematics better and likewise and vice versa.
- 58:06But people often come to study mathematics and don't know the difference between a formula and an equation.
- 58:12And an equation has two sides.
- 58:14An equation has an equal side in the middle.
- 58:16And so what you're creating here is sim.equation.
- 58:19Sim.equ takes two variables, a left-hand side and a right-hand side.
- 58:23That's actually the name of the parameters.
- 58:25So the left-hand side is the derivative of I.
- 58:28So it's saying that the speed at which the number of infected people changes over time, that's the left-hand side of your equation, is equal to, and then the right-hand side of your equation, some constant alpha minus some constant alpha, sorry, times the number.
- 58:42So the speed is related to the number, and that's really the relationship that defines differential equations.
- 58:47Right.
- 58:47And in this scenario, you can change the alpha, the rate of recovery, by providing medicine or just letting people do their thing, you know?
- 58:55Naturally recovery, absolutely.
- 58:57Yeah, yeah, exactly.
- 58:59So in here, you say, you know, given these constants, we're going to, you know, get the equation and then you solve it.
- 59:05You come up with the actual symbolic solution.
- 59:08Symbolic solution.
- 59:09Always blows my mind.
- 59:10You say sim.dsolve, like, does that solve the differential equation?
- 59:14I'm guessing.
- 59:15You give it the equation and the initial conditions and stuff, and you're like, where the initial condition is, we defined a function I.
- 59:22We didn't say what it is, really.
- 59:24But we said at zero, it's the initial condition of like how many people are sick or whatever that turned out to be, which is just...
- 59:30All of which are symbols.
- 59:31Amazing.
- 59:31Everything here is just an idea.
- 59:33Nothing's a number.
- 59:34Everything is just an idea or a concept.
- 59:35Yeah, yeah.
- 59:36We don't know anything about it.
- 59:37We just know that these are the constraints of the equation.
- 59:40And now it gives you, you get the solution and it's, it's an equation.
- 59:45Let's see.
- 59:46I got to go further down.
- 59:47So that's it there.
- 59:48It says that...
- 59:48It gives you the actual solution and then you start plugging in like the numbers, the different conditions, and it gives you the answers, right?
- 59:54Sorry.
- 59:55Exactly.
- 59:55Yeah.
- 59:55You plug in the numbers at the end.
- 59:57So we get the cost if you were to purchase the cure would be 700 and the cost without purchasing the cure would be 500.
- 1:00:04It's just the overall costing into account productivity, offsetting all the impacts of similar type of decisions that governments all over the world will be making.
- 1:00:12And in this particular case, for this cold, Jadier is no, it is not worth getting.
- 1:00:16But good care.
- 1:00:17Don't tell that to the people who are suffering with a fever.
- 1:00:20It's a cold.
- 1:00:22This is not like the common cold.
- 1:00:24This is a cold.
- 1:00:25Yeah.
- 1:00:27We found this chapter really, really neat because when we started doing exactly the same thing going, how do we solve this in R?
- 1:00:35We realized we had to use a completely different approach.
- 1:00:38How do is a bad phrase.
- 1:00:40We went looking at R for an equivalent symbolic mathematics package in R.
- 1:00:45And there is one.
- 1:00:47But really, it's a wrapper for Python's SymPy.
- 1:00:50And so we found ourselves writing strings of Python that you pass to R that R passes to SymPy.
- 1:00:57And yeah.
- 1:00:58Sorry.
- 1:00:59Yeah.
- 1:00:59I think this is your point now.
- 1:01:01That doesn't sound like really like solving it in R.
- 1:01:03Exactly.
- 1:01:05Exactly.
- 1:01:05So then, so we decided, well, no, if we were just to solve this in R, how would you do it?
- 1:01:11And as there is no symbolic library, a library for doing symbolic mathematics in R, we solved it numerically.
- 1:01:18And that just shows like exactly the same problem.
- 1:01:21We get exactly the same answers out.
- 1:01:23But the bit in the middle, the solution steps were completely different in both Python and R for those reasons, which I think is really neat.
- 1:01:31I think that shows that you're concentrating on the problem.
- 1:01:35Rather than the solution steps.
- 1:01:37Absolutely.
- 1:01:38And what you've learned here is that this function that expresses the cost of people being sick, I of T that we talked about is 100 for 100 people sick.
- 1:01:48E to the negative alpha of T, which is, it's pretty awesome.
- 1:01:52I mean, there's never, there's almost always a reason to marvel at the number E. Have you all read the book E, the story of a number? Have I mentioned this before?
- 1:02:01I don't think I have. No.
- 1:02:04This, this book is so good. It just goes back to the history.
- 1:02:08Is it good?
- 1:02:08Literally of just, oh yeah, yeah. It's, I totally can recommend it. So people can check that out if they're...
- 1:02:14E is a ridiculously cool number, right? In terms of, I know Pi gets all the press, but E is a ridiculously cool number.
- 1:02:20It's way cooler than Pi. It's way cooler than Pi.
- 1:02:22I mean, Pi is cool, but it's, if you are into the change of anything, differential equations, integrations, like it's, there's nothing like it.
- 1:02:31I had not heard about that.
- 1:02:32We are going pretty long on time here. So I don't, I want to be respectful of your all time and everything.
- 1:02:37So maybe, is there any other, the problems or areas or libraries that you've made? Actually, let me, let me pick one here.
- 1:02:43Which chapter is the game theory one? Seven or nine? Let's see.
- 1:02:50Wait for it. No, it's not.
- 1:02:54Just one before that. Yeah.
- 1:02:55Or yeah, no, it wasn't before that. Yeah. Got it. Yep.
- 1:02:57The missing one is the linear programming one. All right. Game theory.
- 1:03:01And the reason I want to pull this up is we talked about you, Brent's library and his application.
- 1:03:07How about some Nash pie? I mean, there was a John Nash won the Nobel prize in economics for coming up with, basically proving every, in every game, there was an equilibrium position, which is insane that that's true.
- 1:03:20In a 17 page PhD thesis. Yeah. Incredible.
- 1:03:24And not bad. Not bad. so quick game theory. What is it? People maybe have heard of it, but they don't really know, or maybe they do know.
- 1:03:33I fumbled through the previous one, Gary, but it would make sense for me to take this one.
- 1:03:36Yeah. She should.
- 1:03:37Right.
- 1:03:37So game theory is the study of emergent interactions of if you can kind of make some decisions, describe a system at the lower level, how individuals interact, what happens at, at the higher level. That that's the study of game theory. It's, it's interactive decision-making. A lot of the time you can think of decision-making.
- 1:03:59For example, with that barbershop problem.
- 1:04:02I've discussed at the first stage of, well, if I had this many chairs or this much waiting room, what's the best thing for me? But there you're the only thing that your decision gets hit back with. If you think of a game of tennis, it's playing against the wall. It's playing against that probability. Game theory is just taking it to a slightly different dimension where you have two barbershops. What if you had two barbershops? And if one does this and the other does that, where are the customers going to go? Is the kind of idea.
- 1:04:26Right. Both barbershops could say, expand their waiting room. Both barbershops could hire more barbers or one could say, you know what, if you hire barbers, I'm getting a bigger waiting room. It's like that trade-off. Yeah.
- 1:04:36Exactly. A very famous problem in game theory is the prisoner's dilemma. Two criminals are convicted and are separated and are questioned and they can give evidence about the other prisoner. If they both stay quiet, they both give no evidence. The police won't have enough evidence to send them to prison for a very long time. They'll have to stay for a very short amount of time. So that's in their interest. But the police offer me a deal. And if I give evidence about Geraint, then I'll go free and Geraint will go to prison for far longer.
- 1:05:03Geraint gets offered the same deal and that immediately creates a dilemma that we will both end up getting for a long time. We will both give evidence one about the other. And so that's a very simple model. And that's actually what I came on the show a long time ago to talk about was that actual model and all the interesting stuff you could do with that.
- 1:05:19But this game theoretic chapter is paired with another chapter called agent-based modeling. It's again, one of those points where labeling is interesting because for some agent-based modeling is a subset of game theory. No way it doesn't really matter. And so this chapter is all about emergent behavior. If we can define how decision makers in our system interact, what happens based on what they do, and they being plural, then what is the emergent behavior that you can measure?
- 1:05:46The game that we model in this chapter is there are two taxi firms that serve a community, again, a small town, and they get to decide how many taxis they're going to have.
- 1:06:00The town wants to incentivize these two taxi firms, essentially not to collude.
- 1:06:06They want to incentivize the taxi firms to give better service to the population.
- 1:06:11And so we create the game that allows the tax firms to decide how many taxis they're going to have, one, two, or three.
- 1:06:17And we build a little model that describes what happens if each tax firm has one taxi, what happens if one has one, the other has two, what happens if one has one, the other has three, et cetera, et cetera.
- 1:06:29And then we obtain what is called the Nash equilibrium, which is a measure of if both tax firms know all this and act rationally, what would we expect to happen?
- 1:06:37It's just amazing how these outcomes, it's just so clear, you know, if what's the likelihood of the other person doing or the other player participant taking this particular choice.
- 1:06:50And if or if I take this choice, what are they most likely to do?
- 1:06:54And where are things going to settle in?
- 1:06:55It's really neat how this all sets up here.
- 1:06:58And let me find the section.
- 1:07:00Yeah.
- 1:07:01So what you do is you create a NumPy array or that represents one of the participants outcomes and choices.
- 1:07:10And this one, I guess it's a what is this a zero sum game?
- 1:07:14Because you know, quite not quite.
- 1:07:15It's not zero sum.
- 1:07:16It's symmetric.
- 1:07:17That's symmetric.
- 1:07:18OK.
- 1:07:18So you pass in the transpose of that, which says here's the other player.
- 1:07:22They get basically the opposite of that.
- 1:07:24And then you just say Nash.game and off you go, right?
- 1:07:28Yeah.
- 1:07:28Nash.game creates this game.
- 1:07:30It creates the game object.
- 1:07:31And in the game object, the Nash.py library has all sorts of different algorithms that could be used.
- 1:07:35And the one where we use is something called support enumeration, which is essentially the basic by definition idea.
- 1:07:42And the thing that we do do here is we say, OK, if we are the town hall trying to decide how to let these two tax firms compete, is we essentially are deciding not how we regulate them, but how we incentivize them.
- 1:07:56So what game should we make the two taxi firms play?
- 1:07:59And we do that by essentially say, I guess we will tax you slightly less if you put on this amount of taxis or give you an extra bonus if not.
- 1:08:08And the idea is to what is the smallest amount that the city hall has to kind of guarantee to taxi firms to ensure that their rational behavior would be to give that service to the population.
- 1:08:20So, yeah, then it's just that those three lines you go on the screen right there.
- 1:08:23So while loop where it just increments that offset.
- 1:08:25Yeah.
- 1:08:25And you just say, get the equilibrium from it and off it goes.
- 1:08:30Yeah.
- 1:08:30Very nice.
- 1:08:31OK.
- 1:08:31This is really great.
- 1:08:32And I guess it's worth pointing out.
- 1:08:34I heard of the guy.
- 1:08:35Yeah, that's me.
- 1:08:36I should say that.
- 1:08:37Work on this project.
- 1:08:38So the Nash By Library is myself and former undergraduate.
- 1:08:43Actually, they went on to start their PhD at the School of Mathematics.
- 1:08:46We started this library.
- 1:08:48It's grown quite nicely now.
- 1:08:49To be honest, probably the part of the library I'm the most proud of is the documentation.
- 1:08:54There's arguably a game theory textbook in there if anyone's interested, as well as all the functionality for two-pack games.
- 1:08:59Yeah, fantastic.
- 1:09:01Yeah, it looks really great.
- 1:09:02I'm a big fan of game theory.
- 1:09:03I think it's very simple.
- 1:09:05And yet it reveals pretty amazing answers and behaviors.
- 1:09:09You know, as opposed to something like partial differential equation, which can also reveal amazing answers.
- 1:09:14But the journey to get through it is extremely long versus this.
- 1:09:18You could sit down in the afternoon and explain it to somebody, you know, like that prisoner's dilemma and so on.
- 1:09:24We could all kind of relate to a lot of what's happening there.
- 1:09:26You realize that you're aging.
- 1:09:27But I remember when I first started teaching game theory, everyone had seen the movie A Beautiful Mind.
- 1:09:32But if people listening and are slightly interested in game theory and haven't seen A Beautiful Mind, I'd definitely recommend it.
- 1:09:38It's a Hollywood movie, so have the correct level of expectations.
- 1:09:42It's a really nice movie.
- 1:09:44Russell Crowe plays John Knapp.
- 1:09:46And it's more about, not necessarily about the mathematics, but more about his life, which is incredibly interesting.
- 1:09:51And there's a couple of scenes in that movie that arguably, if you just spend a little bit of time talking about a couple of seats in that movie, you can explain most of the game theory.
- 1:09:59Absolutely.
- 1:09:59All right.
- 1:10:00Well, I get the sense we're a tad bit over time, which is fine.
- 1:10:03But maybe we should wrap it up here.
- 1:10:05There's a bunch of other areas that we haven't covered that are lots of fun that you go into.
- 1:10:10So, yeah, very, very neat.
- 1:10:12But let's kind of wrap it up.
- 1:10:14Maybe we'll ask you the final two questions.
- 1:10:16I want to thank you for having us.
- 1:10:19But I know that you got these two questions coming.
- 1:10:21So, like, oh, do I thank you now?
- 1:10:22Do I thank you later?
- 1:10:23But no, I just really do appreciate you having us on.
- 1:10:25I really do appreciate you as a guest.
- 1:10:27Yeah, you're very welcome.
- 1:10:28It's been great to talk about it.
- 1:10:29All right.
- 1:10:30Now, maybe a lightning round.
- 1:10:32Vince, if you're going to write some Python code, what editor are you using these days?
- 1:10:35I use them.
- 1:10:36I use them.
- 1:10:36Right on.
- 1:10:37Brent?
- 1:10:37I use Sublime.
- 1:10:38I really like having no features.
- 1:10:41I just like typing.
- 1:10:42I don't want features.
- 1:10:43Right on.
- 1:10:44Perfect.
- 1:10:47And then a notable PyPI package that you've come across that you're thinking is worth giving a shout out to?
- 1:10:53I was thinking about this before.
- 1:10:54And the one I'm going to suggest is one called Python Ternary.
- 1:10:58You've got it on the screen there.
- 1:11:00Yeah.
- 1:11:00Python Ternary is a library for plotting on simplexes.
- 1:11:04So for plotting on triangles, want a better word.
- 1:11:08It's the type of plots you draw a lot in evolutionary game theory, as well as other things.
- 1:11:12It's actually a collaborator on a product of mine that maintains this.
- 1:11:15And it's a very nice library for plotting different looking plots.
- 1:11:18I'm sure people think about, well, you could have these different plots on triangle surfaces or, you know, like how much are you at?
- 1:11:25How close are each three different states or something like that?
- 1:11:28Yeah.
- 1:11:28Some of these are really amazing, like this M Cherry one on there where it's got kind of crawling graphs through these triangle different states and so on.
- 1:11:36Yeah, I haven't seen anyone like that before.
- 1:11:38It's very cool.
- 1:11:39It's very cool.
- 1:11:40And it's built on top of Matplotlib.
- 1:11:41So it's essentially the layer to do all the correct scaling and things like that is there for you.
- 1:11:48So yeah, Python Ternary is really cool.
- 1:11:50Yeah.
- 1:11:50Fantastic.
- 1:11:51Grant?
- 1:11:51I think the library I would choose is, it's called Traces.
- 1:11:54It's a small library that, I don't know if you've heard of it before.
- 1:11:58I've got the link here.
- 1:11:59Oh, that one.
- 1:12:00Yeah.
- 1:12:00It does one thing and one thing good.
- 1:12:02It takes moving averages over irregular time intervals.
- 1:12:06And it was a problem which I thought I had until I found this.
- 1:12:10And then it just made life easier.
- 1:12:11I liked it.
- 1:12:12Yeah.
- 1:12:12Very cool.
- 1:12:13Okay.
- 1:12:13I think it's the next link.
- 1:12:14I think it's one just below that.
- 1:12:16This one right here?
- 1:12:17Not that one.
- 1:12:18This one?
- 1:12:19There it is.
- 1:12:19There it is.
- 1:12:20Yeah.
- 1:12:20Yes.
- 1:12:20The Uneven Time Series.
- 1:12:22Yeah.
- 1:12:23Perfect.
- 1:12:23Okay.
- 1:12:23Yeah.
- 1:12:23Oh, yeah.
- 1:12:24That looks great.
- 1:12:25It does one thing and one thing good.
- 1:12:26Fantastic.
- 1:12:26All right.
- 1:12:27Well, yeah.
- 1:12:28And yeah, that's often just what you need.
- 1:12:30Put a link to both of those in the show notes.
- 1:12:33Thank you so much.
- 1:12:34So people are interested in your book or maybe exploring some of these problems.
- 1:12:39What do you tell them?
- 1:12:40Where do they go?
- 1:12:40If you're interested in the book, that's great.
- 1:12:42I think I'd more kind of emphasize just mathematics is so incredibly powerful.
- 1:12:47And it really, really is.
- 1:12:49And it's kind of like I feel that code, open source code, Python, kind of an order of how important each other is.
- 1:12:57And so I think I'd encourage people to investigate those things and you can do amazing things with mathematics and a bit of code.
- 1:13:06That'd be mine.
- 1:13:07I don't know what you think.
- 1:13:08Absolutely.
- 1:13:08No, no.
- 1:13:09Yeah.
- 1:13:10I second that.
- 1:13:11I think my main message is the maths and the software are separate things and they complement each other really well, but they are separate things.
- 1:13:21They are separate things.
- 1:13:22Yeah.
- 1:13:22That's it.
- 1:13:23Fantastic.
- 1:13:23All right.
- 1:13:24And like I said, your book is on GitHub.
- 1:13:26So people can go poke around some of the examples and some of the notebooks and see what we're talking about.
- 1:13:32Make it a little more concrete.
- 1:13:33Make it a little more applied, maybe.
- 1:13:35Yes.
- 1:13:37All right, guys.
- 1:13:38Thanks for being here.
- 1:13:39Thanks for sharing your work.
- 1:13:41It's been a lot of fun.
- 1:13:41No, thank you so much, Michael.
- 1:13:43Thank you.
- 1:13:43This has been another episode of Talk Python To Me.
- 1:13:48Thank you to our sponsors.
- 1:13:49Be sure to check out what they're offering.
- 1:13:51It really helps support the show.
- 1:13:52Listen to an episode of Compiler, an original podcast from Red Hat.
- 1:13:57Compiler unravels industry topics, trends, and things you've always wanted to know about tech through interviews with the people who know it best.
- 1:14:05Subscribe today by following talkpython.fm/compiler.
- 1:14:09Sign up for the Python at Scale conference to connect with your data science colleagues and learn about trends in the Python big data ecosystem.
- 1:14:16Share stories about implementing solutions and find out about innovations in our space.
- 1:14:22Visit talkpython.fm/Python dash at dash scale.
- 1:14:26That's talkpython.fm/Python at scale.
- 1:14:29And use code Talk Python to get 15% off your ticket.
- 1:14:33Want to level up your Python?
- 1:14:35We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:14:39Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:14:44And best of all, there's not a subscription in sight.
- 1:14:47Check it out for yourself at training.talkpython.fm.
- 1:14:50Be sure to subscribe to the show.
- 1:14:52Open your favorite podcast app and search for Python.
- 1:14:54We should be right at the top.
- 1:14:56You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 1:15:06We're live streaming most of our recordings these days.
- 1:15:08If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:15:16This is your host, Michael Kennedy.
- 1:15:18Thanks so much for listening.
- 1:15:19I really appreciate it.
- 1:15:21Now get out there and write some Python code.
- 1:15:22I'll see you next time.