# How to calculate variance of three or more attributes with known frequencies

Question was originally posted on Stack Overflow.

I want to calculate variance of data at a given time where I know the frequency of the conditional and decision attributes. At time $t$ every conditional attribute can have 3 possible values while decsion attribute consists of two classes.

See the picture below for more details:

• How can I calculate the variance of this data snapshot?
• Sample code or an algorithm would be most appreciated.
-
@Zia, it is possible to migrate the questions from one SE site to another. Flag the moderators, do not cross-post. – mpiktas May 30 '11 at 8:22
@Jeromy, we should have posted the @chl edits from stackoverlow, instead of playing a little edit war here :) – mpiktas May 30 '11 at 8:24
ok sorry i didnot know how to do that – Zia May 30 '11 at 8:30
@Zia, no problems, usually the questions that should be migrated are migrated sooner or later, since somebody else flags the moderator. However it is always polite to wait for the answers in the first site you posted the question, before asking anywhere else, and if you do it is always helpful to indicate why the answers in the first site were not satisfactory. – mpiktas May 30 '11 at 8:34
@mpiktas yep. sorry about that. Feel free to change back. I'd just about pressed the button after incorporating the image, and links and so on, and wanted to apply the changes, when I was told it wouldn't apply. – Jeromy Anglim May 30 '11 at 9:06