Sunday, November 4, 2007

I've spent some time thinking about what factors determine exam results. It clearly depends upon the amount of effort you put into it (and the preparations) and your skill level, but also how lucky you are with the tasks you get on the exam. I think I've come up with a mathematical relationship for it

Result = Effort x Skills x Fluke

That is, the exam result is the product of effort, skills and how lucky you are. Here, all factors are non-negative, which gives us a non-negative result as well. A result of zero is a fail, anything above that is a pass.

As we can see, if any of the three factors are zero, you will fail. This is easy to explain. First, if the effort is zero, you didn't even bother showing up on the exam, so you will clearly fail. Further on, if you have zero skills, you don't even know how to read, yet alone remember anything, so no matter how much effort you put into it, you will still fail. Finally, a zero luck means maximum bad luck. An example of this could be to get the following exam:

Task 1 of 1: (100 %)
Is P = NP? Prove your answer.

We can also get some more interesting relationships out of the formula. By dividing by Effort on both sides, we get
Result / Effort = Skills x Fluke.

This tells us that, if you got a non-failing grade on the exam, while the effort approaches zero, you either have extreme skills, or you had a huge amount of luck.

We can also get Result / Skills = Effort x Fluke. So if you got a passing grade, and have zero skills, you put in impossible amounts of effort, or had impossible amounts of luck, which is just not possible, so you could not possibly pass the exam.

So, by using this formula, you should be able to develop a strategy for receiving good exam results  Good luck!

posted on Sunday, November 4, 2007 5:59:20 PM (W. Europe Standard Time, UTC+01:00)      Comments [3]
Tuesday, October 30, 2007

...does not work, it looks like.

I upgraded my installation (hosting this site) of Windows Server 2008 from Beta 3 (June CTP) to RC0 today - over remote desktop! My server is located in a locked server room, so I wanted to try a remote upgrade before asking for the key, and it went well. I extracted the ISO onto the hard drive, started the installation from remote desktop and selected the upgrade option. It turns out that the Windows setup doesn't (luckily) show any dialogs where you have to click next during the upgrade. I had a continuous ping trace running and observed the server going up and down a few times, before it completed the installation and enabled incoming remote desktop connections again. Pretty cool!

But, back to the title. Everything worked well after the upgrade, except SQL Server 2008 July CTP. I kept getting error messages from Management Studio when connecting saying "No process is on the other end of pipe", and this led me into thinking that I had a certificate problem. See this blog post.

But, it turns out that this wasn't the issue. The issue is that Windows Server 2008 RC0 ships with a version of SQL Native Client that is newer than what the SQL Server 2008 July CTP supports, so it just doesn't work. This thread says it will be addressed in the next SQL Server CTP. Until then you have two options:

• Use Management Studio 2008 from another machine to administer SQL Server. This will probably still give you problems if you run SharePoint on the same server, at least my SharePoint installation gets the "No process in end of pipe"-error
• Install SQL Server 2005

For now, I'm going with SQL Server 2005 while I'm waiting for the next CTP of SQL Server 2008. I read somewhere that it is expected in the next one to two weeks. It will probably contain lots of new stuff, like spatial data support, Intellisense in Management Studio and so on. Looking forward to it!

posted on Tuesday, October 30, 2007 6:37:16 PM (W. Europe Standard Time, UTC+01:00)      Comments [0]
Monday, July 23, 2007

It's been a while since my last blog post, so now could be a good time for some updates. First; I'm back in Redmond this summer too, in a summer internship for Microsoft. I'm working on the SQL Server team this year too, but changed teams internally, from the Test Execution Team to the SQL Server Build Team, which is responsible for building (compile, optimize, sign etc.) SQL Server. This means that I design and write software we use to build SQL Server. Right now, I'm working on a system for Peer-to-Peer File Sharing in the build lab, in C#. Building SQL Server involves copying hundreds of GB of data over the lab network, so by doing this p2p instead of centralized, we can reduce the load on the network. This project is really challenging and fun to work on.

So, what about the title of this blog post? This Thursday, all interns were invited to a lecture by J. Allard, and the e-mail said that they would be doing a raffle drawing for one Zune for all the interns after the lecture, but instead they gave away a free Zune for every single one of us! Pretty cool!

I haven't used it too much yet, but so far it looks very good. With it came a 14 day Zune subscription pass, which enables you to download most songs from the Zune on line store for free, which is pretty cool.

I plan to write a few blog posts about how you get an internship at Microsoft, and what it is like, so stay tuned

Below is a picture of a part of the main campus with building 35, where I work, highlighted:

posted on Monday, July 23, 2007 12:28:03 AM (W. Europe Standard Time, UTC+01:00)      Comments [0]
Thursday, May 17, 2007

I am studying for my exam in Performance Engineering these days, and came across a nice way of estimating Pi in the chapter about Monte Carlo simulations (random number simulations) yesterday. The idea is that you use random numbers to estimate something, in this case the number Pi.

Let's take a look at the figure below. Here we have the unit circle (a circle with radius 1 and center in origo) drawn in a coordinate system. Up to the right, in the first quadrant, I have shaded a square area with sides of length 1.

As you probably should remember from school, the area of a circle is A = Pi * r^2, and this circle therefore has an area of A = Pi * 1^2 = Pi. One fourth of the circle is in the shaded area, and this part of the circle therefore has the area Pi / 4. The shaded area itself has an area of 1 * 1 = 1. Then we define R to be the ratio between the area of the shaded part of the circle and the whole shaded area. This ratio is R = (Pi / 4) / 1 = Pi / 4.

Now, let's imagine throwing darts at the shaded area at random (we do not aim for any specific area). Of all the darts hitting the shaded area, a ratio of them, corresponding to R (since there is equal probability for hitting any part of the square), should hit inside the circle. For instance, if the ratio is 0.7, and 10 darts hit the shaded area, 7 should hit inside the shaded part of the circle.

If we throw a fair amount of darts, we should be able to calculate R using the formula R = DartsInsideGreyCircle / TotalDartsInsideGreyArea. As we have from the paragraph above, R = Pi / 4, which means that Pi = R * 4. We have estimated Pi!

The JavaScript simulation below illustrates this. Click start and watch what happens! If you let it run for a while, the result will actually get quite close to the actual value of Pi.

 Coordinates: (x, y) = (0, 0) Hits inside: 0, hits outside: 0 Ratio: R = HitsInside / (HitsInside + HitsOutside) = 0. Estimated Pi value: π ≈ 4 * R = 0. Speed: 1 /s.
Note: If you are reading this through an RSS feed, you may need to open the blog post in a browser to be able to run it.
posted on Wednesday, May 16, 2007 11:26:07 PM (W. Europe Standard Time, UTC+01:00)      Comments [0]
Monday, March 19, 2007

As many others, I also have a voicemail message box for my cell phone number that the caller gets redirected to if I don't answer the phone in something like 15 seconds. What I've found is that 15 seconds is a pretty short time when the phone is ringing and you need to find out where it is. It is OK if you're sitting right next to it, but if it is in some jacket lying somewhere around you're very likely to miss the call.

Therefore I called my phone company (Telenor) today to find out if it is possible to increase this timeout. I got a rather interesting answer:
Dial **61*<Your Voicemail Number>**<Timeout in seconds># on your phone, and you're done.

I don't know if it works only for Telenor customers, but it's worth a try I also found that on my Windows Mobile phone I can actually change this setting under Settings --> Phone --> Services --> Call Forwarding, so that's maybe a more general solution.

So now I've got 25 seconds to find my phone when it rings

posted on Monday, March 19, 2007 1:19:15 AM (W. Europe Standard Time, UTC+01:00)      Comments [2]
Wednesday, February 7, 2007

During Christmas I took two upgrade exams (70-431: MS SQL 2005 Imp&Maint, 70-553: MCSD to MCPD Part 1) to upgrade my Visual Studio 2003 and SQL Server 2000 certifications to .NET Framework 2.0 and SQL Server 2005. Those combined with two I took in Redmond last summer (70-447: MCDBA to MCITP:DBA, 70-554: MCSD to MCPD Part 2) gave me a bunch of new certifications all at once, more precisely 4 x MCTS, MCITP: DBA and MCPD: Ent.App.Dev.

Then the interesting part: All of those come with welcome kits with diplomas, some also with pins and wallet cards in separate envelopes. Therefore, I was wondering if they were going to put everything in one envelope when I ordered something like 9 welcome kits at once. But they didn't, and here the other day I found my mailbox full of welcome kits  Take a look at the picture below where I have spread them out on the bed.

posted on Wednesday, February 7, 2007 1:59:59 AM (W. Europe Standard Time, UTC+01:00)      Comments [8]
Wednesday, December 20, 2006

School is out for Christmas (I had my last exam last Friday), so now I have time do fun things, like coding (surprise).

I think algorithmic programming and databases and SQL queries are cool things, so why not combine them? Yesterday I got an idea of implementing some well-known algorithm in SQL, and I figured out that Dijkstra's Shortest Path algorithm should be fun to implement.

Dijkstra's shortest path algorithm finds, well, the shortest path from one vertex to the other vertexes in a weighted graph. The edges have lengths (or costs or whatever), and the shortest path from one vertex to another is the path where the sum of these lengths are as small as possible. Take a look at the illustration below, showing a graph with some Norwegian cities. The shortest path from Trondheim to Fredrikstad has been highlighted (for those of you that know Norway, not very realistic, but let's pretend it is just for the fun of it).

The algorithm works like a breadth first search that takes the edge weights into account, starting at one vertex and traversing through the graph.

So, how do we implement this in Transact-SQL (MS SQL Server's SQL dialect)? Well, first we need some way to represent the graph. I've created two tables:

The City table is pretty straightforward. The Road table contains one row for every road from one city to another, and the length of that road. Notice that we have two rows for every two cities we have a road between them, one each way. But, now to the real stuff: The implementation of the algorithm:

CREATE PROCEDURE [dbo].[Dijkstra]
@StartCity Int
AS
BEGIN
-- Automatically rollback the transaction if something goes wrong.
SET XACT_ABORT ON
BEGIN TRAN

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Create a temporary table for storing the estimates as the algorithm runs
CREATE TABLE #CityList
(
CityId Int NOT NULL,    -- The City Id
Estimate Int NOT NULL,    -- What is the distance to this city, so far?
Predecessor Int NULL,    -- The city we came from to get to this city with this distance.
Done bit NOT NULL        -- Are we done with this city yet (is the estimate the final distance)?
)

-- Fill the temporary table with initial data
INSERT INTO #CityList (CityId, Estimate, Predecessor, Done)
SELECT CityId, 2147483647, NULL, 0 FROM City

-- Set the estimate for the city we start in to be 0.
UPDATE #CityList SET Estimate = 0 WHERE CityID = @StartCity
IF @@rowcount <> 1
BEGIN
RAISERROR ('Couldn''t set start city', 11, 1)
ROLLBACK TRAN
RETURN
END

DECLARE @FromCity Int, @CurrentEstimate Int

-- Run the algorithm until we decide that we are finished
WHILE 1=1
BEGIN
-- Reset the variable, so we can detect getting no records in the next step.
SELECT @FromCity = NULL

-- Select the CityID and current estimate for a city not done, with the lowest estimate.
SELECT TOP 1 @FromCity = CityId, @CurrentEstimate = Estimate
FROM #CityList WHERE Done = 0 AND Estimate < 2147483647
ORDER BY Estimate

-- Stop if we have no more unvisited, reachable cities.
IF @FromCity IS NULL BREAK

-- We are now done with this city.
UPDATE #CityList SET Done = 1 WHERE CityId = @FromCity

-- Update the estimates to all neighbour cities of this one (all the cities
-- there are roads to from this city). Only update the estimate if the new
-- proposal (to go via the current city) is better (lower).
UPDATE #CityList SET #CityList.Estimate = @CurrentEstimate + Road.Distance,
#CityList.Predecessor = @FromCity
FROM #CityList INNER JOIN Road ON #CityList.CityID = Road.ToCity
WHERE Road.FromCity = @FromCity AND (@CurrentEstimate + Road.Distance) < #CityList.Estimate

END

-- Select the results.
SELECT City1.Name AS ToCity, Estimate AS Distance, city2.Name AS Predecessor FROM #CityList
INNER JOIN City city1 ON #CityList.CityId = City1.CityID
LEFT OUTER JOIN City city2 ON #CityList.Predecessor = city2.CityID

-- Drop the temp table.
DROP TABLE #CityList

COMMIT TRAN
END

If we run it with Trondheim as start city (@StartCity = 1), we get this result table:

This says that from Trondheim, we have a distance 0 to Trondheim, 2 to Bergen and so on, and 6 to Fredrikstad. The Predecessor column says what city we came from when we went to each city. We can see that to get to Fredrikstad, we came from Oslo, and to get to Oslo, we came from Bergen. To get to Bergen, we came from Trondheim. Therefore, to get to Fredrikstad, we took the path Trondheim, Bergen, Oslo, Fredrikstad.

I have included the SQL script to create the database:

posted on Wednesday, December 20, 2006 5:45:10 PM (W. Europe Standard Time, UTC+01:00)      Comments [12]
Sunday, November 5, 2006

A couple of months ago my team from Imagine Cup (Team NTNU) got an invitation to TechEd 2006 in Barcelona from the organizers of Imagine Cup and Microsoft EMEA.

We are going to present our solution and talk a little about our experience in India to the students attending TechEd. We're maybe also going to have a booth with some posters and stuff where we can show our solution. TechEd starts on Monday, so now it's time to get to Barcelona.

It's also going to be exciting to see all the new stuff they are going to show at TechEd. I've never attended a developer conference at this scale, so this is going to be interesting!

posted on Sunday, November 5, 2006 1:28:35 AM (W. Europe Standard Time, UTC+01:00)      Comments [0]