### Maths: Reason 1

Unfortunately the title of this post isn't original. If you've been following the Morrison's adverts you'll know why, and you'll also know to expect more reasons!

As you all probably know, the past few days have been pretty stressful. The main culprit of this stress wasn't only Matlab, it was Stats as well. My coursework has two questions in which I have to use Matlab to do certain things. I've been playing around with Matlab for quite some time this week, and amidst the frustration I could sense I was getting somewhere.

Let me explain (as well as I can), we have to use this 'cdf' function given to us to compute P(Y<=4) and '1-P(Y<=3)' for Y~B(20,p) where p is the probability from 0, 0.02, .....1. It's relatively simple to do if for a 'p' for example p=0.02. All I did was write this in Matlab: cdf(4,’binomial’,[20 0.02]) . However, what I was trying to do was to get Matlab to do this 51 times, for all the values of p which needed to be done. I knew that there had to be an alternative way, there just had to be! If I was expected to do this one at a time, I wouldn't have been told to use Matlab!

I first tried to this:

cdf(4, 'binomial', [20, p])

ans =

1

edit

cdf(4, 'binomial', [20, p])

ans =

1

I continued doing various different things, until my frustration got the better of me and I stopped. (Hence why I wrote three posts yesterday!). I don't know why, but if I can't do something, I sometimes take it personally or get really annoyed at myself. I have to be able to do it myself. I could see what needed to be done, but I just couldn't do it. It's like when you're talking and having a conversation with someone, and all of a sudden your mind goes blank and you forget what you were going to say. As this is me, I get really annoyed at myself until I remember the darn word! The same thing applies to this coursework.

Today, was a nice day and so obviously I was going to start from fresh. I had a plan. It was the only thing that I could think of doing, which would result in me actually finishing the coursework. It wasn't a particularly dangerous plan, but it wasn't very efficient. You've probably already guessed it, and are having a good old laugh (even I'm having a good old laugh now!). Yeah, I used matlab to work out all the actual values of p going up in 0.02's from 0 to 1 for the first part. I then opened and excel document, exported these values onto here and then imported this file as an array into Matlab. (Basically I had two rows, the first with the values of p and the second with the cdf value). I didn't really know how to proceed from here, but spotted a 'sketch' button. (I was getting really excited at this time- something was happening!) We had to do a scatter diagram with the lines joined up, but the blimmin software wouldn't draw the darn graph. However, for my amusement I realised that I could sketch other graphs. So here are a few 'cool' sketches that I produced!

However what I wanted was something like the graph below but not like the stems, and only the green bit! I continued to play around with Matlab and to try and produce a graph. It was then that I thought, what about if I transpose to two rows that I have? I tried this and saved the array under a new name, and wow what did I have, but the scatter graph that I needed!! This is the reason number 0.5. Ha, I was pretty impressed at this stage, and after a while realised that I could make the round circles for the scatter plot smaller and plot another graph which joined up the dots. My work was half done. I was pretty up beat. But this had taken me ages to do, and it was a pretty inefficient way of doing it. I wouldn't have minded continuing this way for the second part, however I was 'bored' by this so to speak.

I went for a little 'walk' and then it happened! I saw L. This was the second time in my life in which I had been so happy upon seeing her! She was with another colleague, however I just had to tell her whether she could come see me in the computer room after her tea. (I was going for a 'walk' so made sense for this). And true to her word she came. She couldn't believe that I had done what I had (I told you it wasn't the best method) and then proceeded by helping me and Jake. (Jake had been trying to get his loop to work, but I'd been thinking along the lines of getting the darn report finished!). We realised what we hadn't been doing ( I'd just been writing p!) and then it all clicked into place. We thanked L and then we had a 30 minute break chatting to her, about how rubbish stats was and stuff in general. (I was outnumbered, L and Jake like stats *sniff* also thanks to L for helping me get the money :D)

Anyway, this is reason number 1. The sense of having accomplishing what I set out to do is very soothing and exciting. I had been pulling my hair out for the past two days, however today it's all fallen into place. If L hadn't corrected us, I would have done it the long and tedious way, but I would still have completed it. It was like a jigsaw puzzle, completed. How I felt after I climbed the stairs of the mss building again, today. ;) The next question doesn't require using Matlab as much as this question did, which is a relief. I now only have to complete the last question- great, just great!

So there you have reason number 1. I have probably mentioned this reason before, indirectly, but today I felt it! It's weird how when one thing works, you become positive about everything else you're doing. I'm going to have a look at the Sequence's coursework and last week's mechanics lecture notes in a few minutes. But I'm not seeing no time constraints on these activities like I normally do. I know that I will do them both by tomorrow. (and my Linear Algebra homework- crap I'd forgotten again!).

Now this seems a good place to end this post, but today something else happened in the Linear Algebra lecture, which I can't help but mention! During the lecture, Prof S was writing on the board and he heard some people talking. He stopped writing on the board and turned around, pretty angry! He actually knew who was talking and identified the row and the people who were talking, and asked whether they had a question. And then quote, 'You're taking the piss. I gave you a warning! I don't tolerate talking in my lectures! If you want to learn then please come to the lectures, if not then talk elsewhere.' (as best as I can remember).

Now it'd be so cool if every lecturer did this. This is the war against the people who talk non-stop and loudly, disturbing others. I guess sometimes, there may be no point in telling a certain person to shut up or kicking them out, but if you kick someone out once then you're showing the students that you're willing to do this. Hence, the students will be wary of this and obviously be more cautious. Like today, I don't think anyone else dared to talk after that! It's very annoying when people talk, especially when you're in the 'zone'. I used to do a small tally in the margins, in Dr C lectures last semester on the amount of time the people talking annoyed/distracted me. I soon realised that was pointless since I didn't have enough paper for that! :D (I'm not saying I never talk, but I tend to write down what I say on the Tweenies papers!)

I must also mention, that I ended up walking up the stairs twice today. Once with Noddy (muhahaha) and the second time because I was racing Jake to n floor. I narrowly lost, and I put this down to the fact that it was my second time during the day doing this. I'm going to be walking up them stairs everyday. I've decided it's the best way of keeping in shape and it can't exactly harm me. (Only takes about four minutes!) It was another oscillating day today- I had three blimmin nightmares last night. The first one was freaky and was at five. The other two had something to do with maths, but it wasn't in a good way! I'd rather be dreaming about Linear Algebra.

Anyway, as I continue to drag this post out (thankfully this is not a real advertisement!), only 94 people came to sequence and series lecture today. The lecturer himself counted this. We started at 10 past-ish (due to student union people campaigning) and finished at 2:40. The lecturer mentioned that we're paying £3000 for our education so how come only 94 people are coming (93 after someone walked out). However, the people that are not there shouldn't be his concern. We're paying and we're there. That should be the issue. ~sigh~ More work for me I suppose, and the staff members present at the example class :D (woohoo!)

So the only positive here is that there's lot more reasons to come and Matlab can draw some cool graphs!

## 5 comments:

Jake like statsEven though I am aware this statement doesn't refer to me; it still makes me feel uncomfortable.

I had previously assumed that the set {Jake X| Jake X likes stats} was the empty set.

Haha, I think Tweenies Jake needs a new name! I think I'll refer to Jake as Fizz now (since Fizz has left)! :D (to avoid confusion and I don't want to make you feel uncomfortable!)

Carry on assuming that :) It's makes sense :D

You produced fine MATLAB codes, feel free to post them at LP.org:

http://en.literateprograms.org/Category:Programming_language:MATLAB

You could reallyuse MATLAB more directly:

N=20;

p=0:0.01:1;

b4 = binocdf(4,N,p);

b3m1 = 1- binocdf(3,N,p);

inan = ...

@(x,i)reshape([x(:)';repmat(i,1,length(x));...

repmat(nan,1,length(x))],3*length(x),1);

bnan = ...

@(x)reshape([x(:)';x(:)';...

repmat(nan,1,length(x))],3*length(x),1);

figure('Color',...

[0.9412 0.9412 0.9412 ]);

h1=fill([p(:);0],[b4(:);0],'r',...

'facecolor',[.5 .5 0],'edgecolor','none');

hold on

plot(p,b3m1,'-','color',[.5 0 .5],'linewidth',1);

h2=plot(bnan(p),inan(b3m1,0),'-',...

'color',[.5 0 .5],'linewidth',2);

hold off

legend([h1,h2],{'B^{-1}_{20,p}(4)', ...

'1-B^{-1}_{20,p}(3)'});

xlabel('p\in[0,1]');

Thanks, I'll see what I can do when I get the chance. Although I now see where I went wrong.

I followed the first paragraph of what you wrote, but then all I'm seeing is squiggles (I get what you're doing, but it looks like a lot of input!). It's a shame I haven't got MATLAB at home, but when I get back to uni, I'll have a go at inputting what you've suggested.

(Please tell me that you didn't know that from memory!) :p

Post a Comment