Tuesday, February 23, 2010

Probability to observe the same number calling Random.Rand()

It’s not an efficient query. Just a game…
for (int j = 1; j < 8; j++)
{
    int numElements = (int)Math.Pow(10, j);
    var numersList = Enumerable.Repeat(0, numElements).Select(
        i => Convert.ToDouble(random.Next()))
        .Distinct().OrderBy(i => i);
    double probabilityGetSameNumber = 1 - (double) numersList.Count()/numElements;
    Console.WriteLine(
        "Rand() was called {0} times. Same number was observed in {1} % cases",
        numElements, probabilityGetSameNumber);
}

Results:

Num of Rand() calls Same number observed in % of cases Cases count
10 0 0
100 0 0
1000 0 0
10000 0 0
100000 0.00002999999999997 3
1000000 0.00024100000000004 241
10000000 0.00234760000000001 23476

 

Technorati Теги: ,,,

Random clicks

http://www.evernote.com/about/home.php

http://www.sendmehome.com/

Wednesday, February 17, 2010

Impossible to log SQL 2008 performance counters under Windows 2008 64 bit?

Here is some strange problem I’ve experienced (right now it seems to me as a bug in Windows 2008 64 bit):

I have an environment with Windows 2008 64 bit and SQL Enterprise 64 bit.

To begin with - it's possible to see SQL-related performance counters values only in perfmon opened from SysWow64 (i.e. 32 bit) - they are not present in 64-bit perfmon.

Now, if I open perfmon (32 bit) and add any SQL counters (e.g. SQL Latches) to the "Performance Monitor" section I can see that those values are updated "live" in perfmon graphs.

Yet, if I create a new Data Collector Set for the same values under Data Collector Sets -> User Defined - the values for SQL counters are not being stored in the created log file. If I add some other counters (e.g. Processor) they ARE saved.

Seems that this is some sort of bug/problem related to 64 bit…

There are some clues on this problem in two following articles:

but both do not help (for the first one – there is no such service anymore in Windows 2008…

Many, many pretties... piled high beyond the sky

Yes, it could be a lot more small rectangles in it, I know ;o)
(But you can't look too far - when you look too far - it looks back).
Strong Server
Technorati Tags: ,