泊松分布在容量管理中的应用

其实是泊松分布的经典应用:

已知某呼叫中心每小时会进ci个电话,每个电话平均时长为tp,则在任意给定时刻,并发电话的为x的概率服从泊松分布。此处假设不同的电话是完全独立事件。

并发电话为x的概率,等同于在tp时长内,进入x路电话的概率。在tp时长内,平均会进的电话数为tp*ci。因此,并发电话小于或等于x的概率为(excel公式):

POISSON(x,tp*ci,TRUE)

其中最后一个参数TRUE,表明这里计算的是并发电话小于或者等于x的概率;如果用FALSE,则只计算等于x的概率。

此公式可用于呼叫中心容量规划,比如:如果已知呼叫量和平均通话时长,则要确保容量在99%的情况下够用,则只需求x,使得POISSON(x,tp*ci,TRUE)>0.99。

在某呼叫中心,把历史数据应用了一下,符合度很高:

call_vol_verification

其中横轴是时间,黄色为实际并发量,蓝色为按照0.999计算出的并发量上限。

如果把横轴改成按照实际并发量排序,则得到:

call_vol_verification_2

可以看到实际并发量几乎总是在预计容量之下。几个实际并发量高于预计容量的情况,后来证实都是系统出了故障,导致客户竞相反复拨打,意味着不仅原来的参数不再适用,独立同分布的假设也不再适用。

 

Illusions well illustrated

The documentary Test you Brain from National Geographic is awesome!

Illusions are well known to human, but not all of them have been well illustrated in action. The problem is, some of the illusions are very  best described in experiment to shows all the intricacies. For that we need carefully designed experiments and video making. This is the first time I saw something like this is made.

As an example, here’s how this documentary illustrated an attention saturation situation devised in David Copperfield’s studio:

First you see a magician told you that he wanted to do something not at all legal with money. After showing you the cash, then messing around it, the silently putting it back to his pocket, you’re asked, “did you notice anything?”.

vlcsnap-2012-01-30-08h41m37s953

Of course you didn’t. Then the video rewind and show you what had happened before and after.

Then another video shot by a camera from another angel showed you these changes were made actually well you were watching. You didn’t notice only because you didn’t pay attention to them.

vlcsnap-2012-01-30-08h47m43s393

vlcsnap-2012-01-30-08h42m18s374

So after you see this, you cannot help to say to yourself, aha, that’s how they’ve deceived me. But then you have to rethink about perception and illusion.

While it’s not available in Youtube, we Chinese can already watch it here:

Documentaries that worth noting

Have been watch documentaries for years now, especially BBC ones. Looking back, not every one of them left the same impression or impact. Here are the ones I’d like to share with others (With links to docuwiki.net, where you can find more information about these documentaries):

Another great documentary from Simon Schama

After “Power of Art”, I’m a fan of Simon Schama now. Two weeks ago I downloaded “A history of Britain”. I haven’t finished it yet, but it’s already ranked very high in my list. 🙂

Something in common in these 2 documentaries: In both of them, there are great music. The music in the opening scene of “Power of Art” is lovely (Moonlight Sonata?), the music in the opening scene of “A history of Britain” is also very intriguing, anyone knows what it is?

中国什么时候算强大了?

奥运会赛程过半,中国人的自豪感自信心水涨船高,论坛里不时有人发一些自信心爆棚,让人目瞪口呆的帖子。

我觉得,国家肯定是发展了。但是,对于我们这样一个历史悠久、人民勤勉,人口众多、重视教育的大国来讲,还是要有更高的目标。这个更高的目标很难具体化,但是,最近我经常在看南方公园,觉得深受启发。我觉得我可以提一条判断标准:

如果有一天,在我们国家,会有这样一部给成年人看的动画片,它讽刺,有趣,它得罪公安、工商、税务、老师、领导、明星、平民、儿童、少数民族、残疾人等等等等,而只会被一笑而过;可能有人抗议,诉讼,但没有人诉诸领导,要求禁播,中国就真的强大了。

立贴为证!

Power of Art by Simon Schama

I downloaded this series 6 moths ago. I tried watch it but seemed that the content seemed too difficult for me – This is the first time I take on a documentary that is art subject. My vocabulary is simply not enough.

In the past days, I forced myself to take notes on sentences that I didn’t understand, and then lookup, and then review the video. Till yesterday night, I finished the first 4 parts. What I can say is, it worth every minute of the effort!

A lot of praise out there already for this great documentary. There’s not much I can add to that. I only hope the future generation will have this kind of art eye-opening in their classroom, or I’ll have to show them this great documentary.

imsc12.ime causes mmc.exe to freeze?

I had suffered from this annoying problem for a long time – Every time I opened the compmgmt.msc file, and tried to check the system log (or application log, or any other log loged by Event Log), I could open the event property windows normally by double click on a log entry. But as soon as I closed the event property window, the whole application got frozen. That is, I can move the main windows, maximize it, minimize or restore it, but the content of the window became blank. Soon after that, the title bar of mmc told me that the application stoped responding.

I couldn’t figure what’s happening until one time, I used SystemInternals’ process explorer – I love this tools – I found that there’s a new thread being spawned when I opened the event property window. Yet when I closed the window, the thread didn’t terminate. Just a desperate move in order to solve this problem, I killed the thread using procexp. Magically, the mmc window restored to its normal state!

I tried to reproduce this scenario, some time it works, other times it failed.

Yesterday, when I got an error, I check the log and got stucked, again! When I fired process explorer and trying to kill the stuck thread, this time, the worst thing happened, process explorer got stuck!

Finally, I would have to solve the whold problem. I launched visual studio, and created a new project, and attach to mmc.exe process. I waited for all the symbols got loaded and paused the process.

There they were! In the thread window, there were four threads, I repeated the resume and pause for some time. Everytime the process pauses at the same thread. So I can assume this thread was busy doing something. The call stack show that this thread is doing somthing with the IME engine – I’m working on an simplified Chinese platform.

There was another thread with a paused flag, I switched to this thread, call stack show it was paused in a WaitForSingleObject function call. It must be the main thread. A peek at The bottom line of the calling stack confirmed this.

So, could it be the IME engine causes this frozen?

I investigated the loaded modules of the process, and the imsc12.ime seemes suspicious. It was the module sit on top of the call stack of the busy thread.

I opened the c:\windows\system32\ folder and found the file. In the security property of the file, I denied everyone from accessing this file. After that, I opened the compmgmt.msc and double clicked on an event. With cautious and anxiety, I closed the window… IT WENT WELL! THE PROBLEM GOT SOLVED!

ps, I searched the net with all the possible keywords combination. It seemed nobody else ever had this problem.

An ugly implementation

Recently, I’ve been working on an CPropertySheet based application. It has multiple property page. Along with every property page, there’s a working thread behind the scene. I use a timer and a critical section kernel object to syncronize the working thread and the GUI update.

I tested the code with just one page, it works fine. But when I add the second page to the property sheet, the code ends up with an assert error on the SetTimer function call with the OnInitDialog funciton of the PropertySheet.

I was confused by this odd – it takes me a whole day to figure out what happened to the second property page. Finally I realized that the page would not be created till the user clicked the tab and activate the hiding page. So in OnInitDialog function, all propertypages’ m_hwnd is NULL – except for the first page, it has been activated automatically – that lead to the ASSERT error.

To solve this problem, I use a loop to activate the pages within the OnInitDialog function of propertysheet and then SetTimer. It works, but what an ugly implementation! If anyone has a neat approach, pls let me know.