Monday, 29 August 2011

Euclidean Distance

In mathematics, the Euclidean distance or Euclidean metric is the "ordinary" distance between two points that one would measure with a ruler, and is given by the Pythagorean formula. By using this formula as distance, Euclidean space (or even any inner product space) becomes a metric space. The associated norm is called the Euclidean norm. Older literature refers to the metric as Pythagorean metric.

Despite the development of numerous types of geometry, Euclidean distance is still by far the most geometrical tool of applied scientists. For example, statisticians find it useful to calculate the proximity between samples.

Application in Co-ordinate Geometry:

In one-dimension: Euclidean distance will be the absolute value of their numerical difference.

Euclidean Distance = I x-y I

In two-dimension:

If u=(x1,y1) and v=(x2,y2) are two points on the plane, their Euclidean distance is given by

Euclidean Distance= sqrt [ (x1−x2)2+(y1−y2)2 ]

Geometrically, it's the length of the segment joining u and v.

In three-dimension:

In three-dimensional Euclidean space, the distance is

Euclidean Distance= sqrt [ (x1−x2)2+(y1−y2)2 + (z1-z2)2 ]

In N dimensions:

In general, for an n-dimensional space, the distance is

Euclidean Distance= sqrt [ (a1−b1)2+(a2−b2)2 + (a1-b2)2 +….+ (an-bn)2]

Using the Euclidean distances, we can create what is known as the Euclidean Distance Matrix. A Euclidean distance matrix is a matrix (two-dimensional array) containing the Euclidean distances, taken pair-wise, between a set of points. This matrix will have a size of N×N where N is the number of objects.This matrix is symmetric in nature – that is Xi,j = Xj,I.

Example:

Below are various objects. Now we will calculate the Euclidean distance between each of them, pair wise

File:Clusters.svg


The Euclidean distance matrix would be:


a

b

c

d

e

f

a

0

184

222

177

216

231

b

184

0

45

123

128

200

c

222

45

0

129

121

203

d

177

123

129

0

46

83

e

216

128

121

46

0

83

f

231

200

203

83

83

0













Posted by

Saurabh Agarwal

Finance

Better understanding of Cluster Analysis

The second day began with a better and clear understanding of the concepts that we learnt yesterday and progressed on to understand many other new ones. The SPSS software, for me, till before yesterday was a mechanical exercise to extract some outputs for a given set of data. After these sessions I realised the importance of analysing the output for various strategic business decisions.

As we learnt more on cluster analysis and delved more into hierarchical clustering and moved on to k- means clustering, I would like to discuss a few examples where I think the concepts can be useful.

The approach to cluster analysis can be used to classify hedge funds given the lack of classification of ‘pure’ hedge funds type. The various parameters that can be used as a basis of hedge funds classification are:

Ø Asset class

Ø Region of investment

Ø Trading strategy

Ø Liquidity of investment strategy

K-means clustering can be used to classify hedge funds on the basis of the above-mentioned attributes. K-means is used when the number of objects is more than 50 and if the number of objects is less than 50, we use hierarchical clustering. This method identifies the closest cluster centre (in terms of a distance measure) for each hedge fund and assigns the hedge fund to that cluster.

Now something about the 0s and 1s of the proximity matrix table...

The logic of similarity and dissimilarity is a little confusing. Therefore the thumb rule is:

Lesser distance and more proximity mean there is dissimilarity and there are 0s in the diagonal of the matrix.

Lesser distance and lesser proximity mean there is a similarity and there are 1s in the diagonal of the matrix.

Difference between Euclidean distance and Squared Euclidean Distance

Deriving the Euclidean distance between two data points involves computing the square root of the sum of the squares of the differences between corresponding values.

Euclidean Squared distance metric uses the same equation as the Euclidean distance metric, but does not take the square root. As a result, clustering with the Euclidean Squared distance metric is faster than clustering with the regular Euclidean distance.


Okay. That was from my understanding of today’s sessions!!

Author: Ankita Agarwal (13008)

Group: Finance_6


An Insight Into Jaccard Measure

The Jaccard index, popularly known as the Jaccard similarity coefficient is a static used for comparing the similarity and diversity of sample sets. The Jaccard coefficient which measures similarity between sample sets, and is defined as the size of the intersection divided by the size of the union of the sample sets:

J (A, B) = |A Ώ B|

| A U B|

The Jaccard distance, which measures dissimilarity between sample sets, is complementary to the Jaccard coefficient and is obtained by subtracting the Jaccard coefficient from 1, or, equivalently, by dividing the difference of the sizes of the union and the intersection of two sets by the size of the union:

J’ (A,B)=1- J(A.B) = | A U B|-|A Ώ B|

| A U B|

Jaccard’s coefficient (measure similarity) and Jaccard’s distance (measure dissimilarity) are measurement of asymmetric information on binary and non binary variables.

Example: Similarity of asymmetric binary attributes

Given two objects, A and B, each with n binary attributes, the Jaccard coefficient is a useful measure of the overlap that A and B share with their attributes. Each attribute of A and B can either be 0 or 1. The total number of each combination of attributes for both A and B are specified as follows:

M11 represents the total number of attributes where A and B both have a value of 1.

M01 represents the total number of attributes where the attribute of A is 0 and the attribute of B is 1.

M10 represents the total number of attributes where the attribute of A is 1 and the attribute of B is 0.

M00 represents the total number of attributes where A and B both have a value of 0.

Each attribute must fall into one of these four categories, meaning that

M11 + M 01+ M10 + M00 =n

Jaccard similarity coefficient J is given by

J= M11

M11 + M 01+ M10

Jaccard distance J’ is given by

J’ = M 01+ M10

M11 + M 01+ M10

Sakshi Goel

13100

Finance Group-1

Box Plots..What language is that?


Ok rule of thumb for today! Use Hierarchical Clustering when number of objects to be clustered is less than 50 and K- Means Clustering when the objects are more than 50.

Suppose the number of objects in my analysis is more than 50 and I have to use K-Means clustering. How do I actually go about doing this?!!

Simple, I decide my objective of clustering, select the variables and cluster them. I will hopefully get a number of clusters with enough number of cases in each to make the clusters significant (AND they’ll be identifiably different from each other!!).

But what about all those clusters that I see in there with number of cases that read the dreaded number 1 and 2 and bla bla bla...What do I do about those?

First find out if they are outliers. Start by taking a smart and logical guess as to which variable out of the clustered ones could be the reason for them being outliers. Then create a box plot for that variable and identify and eliminate the outliers.

Remake the clusters, do their profiling in order to understand the difference in between the groups and then make suggestions and draw conclusions to satisfy the objective.

Ok so all of that sounds manageable, pretty simple in fact once I get the hang of it, except for that one little thing called box plot! If only that made more sense, I’m sure I could ace this!!

Lets look at Box Plots!

In 1977, John Tukey published an efficient method for displaying a five-number data summary. The graph is called a boxplot (also known as a box and whisker plot) and summarizes the following statistical measures:

  • median
  • upper and lower quartiles
  • minimum and maximum data values
Box Plot



The plot may be drawn either vertically as in the above diagram, or horizontally.

Interpreting a Boxplot

The boxplot is interpreted as follows:

  • The box itself contains the middle 50% of the data. The upper edge (hinge) of the box indicates the 75th percentile of the data set, and the lower hinge indicates the 25th percentile. The range of the middle two quartiles is known as the inter-quartile range.
  • The line in the box indicates the median value of the data.
  • If the median line within the box is not equidistant from the hinges, then the data is skewed.
  • The ends of the vertical lines or "whiskers" indicate the minimum and maximum data values, unless outliers are present in which case the whiskers extend to a maximum of 1.5 times the inter-quartile range.
  • The points outside the ends of the whiskers are outliers or suspected outliers.

Boxplot Enhancements

Beyond the basic information, boxplots sometimes are enhanced to convey additional information:

  • The mean and its confidence interval can be shown using a diamond shape in the box.
  • The expected range of the median can be shown using notches in the box.
  • The width of the box can be varied in proportion to the log of the sample size.

Advantages of Boxplots

Boxplots have the following strengths:

  • Graphically display a variable's location and spread at a glance.
  • Provide some indication of the data's symmetry and skewness.
  • Unlike many other methods of data display, boxplots show outliers.
  • By using a boxplot for each categorical variable side-by-side on the same graph, one quickly can compare data sets.

One drawback of boxplots is that they tend to emphasize the tails of a distribution, which are the least certain points in the data set. They also hide many of the details of the distribution. Displaying a histogram in conjunction with the boxplot helps in this regard, and both are important tools for exploratory data analysis.

Alright that was informative! Those weird boxes with lines and stars at odd places definitely make more sense to me now. Kind of like learning a new language...

Hope it helped!!

Priyanka Bagla (13029)..

Finance_Group6

The Chi Square

The chi-square test is a statistical test used to examine differences with categorical variables. The chi-square test is used in two similar but distinct circumstances:

  • For estimating whether two random variables are independent
  • For estimating how closely an observed distribution matches an expected distribution (a "goodness-of-fit" test)

The Two Types of Analysis

Test for Association: Test for Association is a (non-parametric, therefore can be used for nominal data) test of statistical significance widely used bivariate tabular association analysis. Typically, the hypothesis is whether or not two different populations are different enough in some characteristic or aspect of their behavior based on two random samples. This test procedure is also known as the Pearson chi-square test.

It is to be understood that the chi-square test is needed when the data are categorical (or nominal) in nature. This measure is based on the fact that we can compute the expected frequencies in a two-way table (i.e., frequencies that we would expect if there was no relationship between the variables). For example, suppose we ask 20 males and 20 females to choose between two brands of soda pop (brands A and B). If there is no relationship between preference and gender, then we would expect about an equal number of choices of brand A and brand B for each sex. The Chi-square test becomes increasingly significant as the numbers deviate further from this expected pattern; that is, the more this pattern of choices for males and females differs.

Goodness of Fit Test: Goodness-of-fit Test is used to test if an observed distribution conforms to any particular distribution. Calculation of this goodness of fit test is by comparison of observed data with data expected based on the particular distribution.

Requirements of Chi-Square Tests

  • Data is typically attribute-based (discrete). At the very least, all data must be able to be categorized as being in some category or another)
  • Expected cell counts should not be low (definitely not less than 1 and preferable not less than 5) as this could lead to a false positive indication that there is a difference when, in fact, none exists
  • The only assumption underlying the use of the Chi-square (other than random selection of the sample) is that the expected frequencies are not very small. The reason for this is that, actually, the Chi-square inherently tests the underlying probabilities in each cell; and when the expected cell frequencies fall, for example, below 5, those probabilities cannot be estimated with sufficient precision.

Applications of Chi-Square Test

Chi-squared test of independence is a very useful tool for any predictive analytics professional. When analyzing marketing research results, the chi-square statistical test comes in most handy when analyzing cross tabulations of the survey data. Since crosstabs show the frequency and percentage of responses to questions by different categories of respondents (gender, income, profession, etc.), the chi-square test can tell us whether there is a statistical difference between the categories in how they answered the question.

  • To verify the influence of gender on purchase decisions. For example, are men the primary decision makers when it comes to purchasing a big ticket items? Is gender a factor in color preference of a car?
  • To test if altering the product mix (% of upscale, mid-range and volume items, say) has impacted profits by comparing sales revenues of each product type before and after the change in product mix
  • To determine if certain types of products sell better in certain geographic locations than others. For example, the type of shoes sold in winter depends strongly on whether a retail outlet is located in the north versus in the south

References:

http://www.simafore.com/blog/bid/54594/How-to-use-Chi-Square-test-for-3-common-business-analytics-problems

http://www.polarismr.com/resources/chi-square-formula/

http://www.statsoft.com/textbook/basic-statistics/

http://www.simafore.com/blog/bid/55363/3-basic-concepts-which-underpin-the-chi-square-test

Group No.: Group 4 – Marketing

Author: Kanishka Pasari