
The k-function is one of many spatial statistics functions. It was first described by Eugene Pol’shin in his 1957 paper “On some new characteristics of certain graphs”. Since then, it has become an integral part of studying surface pattern distributions.
The k-functions we will look at today are the cluster shape index (CSI) and local density index (LDI). Both of these indices measure how clustered or dispersed a set of points is within a given distance. They both start as the mean value of all distances between pairs of points, but then they subtract or add extra values depending on if there is an isolated pair of points or not.
Their differences come down to whether you use the maximum or minimum value when calculating the average. For the CSI, you take the absolute difference of this value and then divide that into the initial average. This is done for every possible pair of points and then summed up to get your overall statistic.
For the LDI, instead of dividing, you multiply! After doing this, you sum up all of the individual products to find your total. These sums can be normalized to get rid of arbitrary factors like the number of points or unit length, which makes comparisons more straightforward.
There are several reasons why these two indices matter. First, knowing how concentrated or spread out a dataset is can give us insight into what areas of the space contain similar patterns or not.

Let’s look at an example of how to use the kth-percentile curve with a dataset that contains two variables, value, and percentile.
In this case, we will be finding the 95th percentiles for the variable cost, so we can calculate this by taking 5% of the total data set size. In other words, take 2% of the data set as our cutoff point.
To do this, we will create a new column in our data frame which we will name “k95.” This will act as our kth-percentile column since it is telling us what percentage of the data set is larger than or equal to the given number.
We can then add this column to our existing data frame using pandas` DataFrame.rename() method.

The median is another way to find an element’s middle. Like the average, the median finds what position lies in the middle of a collection. However, whereas the average calculates how much it costs to buy an item and divides that by how many items there are, the median only looks at how many elements there are and which one comes right after the other.
The median was first defined in 16th-century France for use in counting sheep. Since then, it has been extended to almost every field! It is now called the “arithmetic” or “integer” mean.
Just like the average, the median can be calculated using either absolute value sums (so if there are three numbers, the average is (5 + 10 + 15), but the median is just 5) or relative values (the sum of all the numbers divided into half of the number of terms).
However, instead of dividing each term by two, you take the smallest member and multiply it by 2, add this new number to the next smaller piece, repeat until you get a number bigger than the original small piece, and then take the highest number. This process is repeated with the second smallest piece and so on until you have your result.

The average of several things is called the mean or center of gravity. For example, if you were to take all the heights in your room and add them up, then divide that total by how many there are, this would be the mean height.
Your bedroom’s ceiling could be the mean height!
The mean function is one of the most important concepts when it comes to spatial statistics. It can also be the hardest to understand, which is why I will go into some detail about it here.
After defining the mean function, we will examine three other functions that are related to the mean: the median, mode, and range. These functions come in different forms depending on the type of data set being analyzed, so they will not be discussed in depth here.
Mean Defined
Definition: The mean of a set of numbers is simply their sum divided by the number of terms.
So, the mean of these two numbers is 5 because they both have a single element (they do not contain a zero), and their sum is 10, which is why the mean is 5.
There are no general rules about what numbers should be used as denominators, but for practical purposes, just use 1.000, 0.500, or whatever seems appropriate.
NOTE: When calculating the mean of more than 2 numbers, make sure to carry out the process correctly before moving on to the next step.

The mean is not the most common value of a number set. This makes sense because the average contains arithmetic information that only tells you how many times an element in the set was used as a whole.
The median is also not ideal, because it does not take individual values into account. The middle value is always included when calculating the median, so some very large or very small numbers can influence which numbers make up the middle.
The modal value is the value that occurs the most frequently in a given set. This is why it is called the “mode”- there are more instances where this value occurred than any other.
A related concept to the modal value is the term quasi-mode. A quasi-mode has a similar definition but instead says what type of structure the mode represents. For example, the word ‘quarter’ – every fourth item in a collection is the mode of quarters.
Given enough data, it is possible to determine if an object is a mode by determining whether there is another copy of that same object nearby. If there are multiple copies of something, then that thing is no longer the unique most frequent occurrence of the set.

The range function is one of several spatial functions that calculate an element’s length or width. It allows you to find the distance between two points, as well as determine which point is closer to the other.
The range function takes two inputs and returns a value relative to its second input. In this case, the first input is called the lower limit and the second is referred to as the upper limit. These can be confusing because there are only two limits, but the function adds another part to it – breakpoint. A breakpoint is an additional parameter in the equation that determines when the function should stop calculating distances.
For example, if your breakpoint was 0.5, then the range function would not include the halfway point in its calculations. Therefore, any elements with a longer length than 0.5 will give a very inaccurate result! This could potentially mislead someone else trying to figure out how far away one object is from the next.
Knowing what each part of the range function does can help avoid these issues. So, let’s take a look at some examples.

The interquartile range (IQR) is another way to describe variability in a set of numbers. It comes from the name “inter quartile”, which means between percentiles there are 25% and 75% of the data.
The IQR can be thought of as the distance between the top and bottom average values. For example, if the average value was 5 and the bottom value was 1 and the top value was 10, then the IQR would be the difference between the highest and lowest values, or 9 here.
So why is this important? Because it gives you an idea of how spread out the averages are and how close together some of the extremes are.
The lower the mean, the higher the variance so having a high IQR indicates that there are lots of very low and very high scores. This may indicate that there is little consensus about the test results or that the test is not well designed.

The standard deviation is another way to describe how to spread out or concentrated values in a set of numbers. It acts similarly to the mean, but instead of taking an average, it takes the difference between the highest value and the lowest value and divides that number by two.
The standard deviation, therefore, acts as a measure of variability, or how much each element within the dataset varies from the rest.
It is important to note that even though this seems like it would make sense, you cannot use the term ‘standard deviation’ when the data does not contain at least three elements. You will get an error message stating so!
Exceptions include when you want to know whether one piece of data is more variable than another, in which case you can calculate the standard deviation. This happens very rarely, if ever!
Standard deviations are often used along with the median to determine what statistic describes the middle value of a collection. For example, say there are only two numbers, rs, and their mean equals 5. Then the SD would be computed using the formula above, and the result would be 2.5.
Since the mean was five, twice two makes four, and the other number was two, making a total of six. Six is greater than five, so the middle value is defined as five plus half of six, or equal to five and a half.
This process can be repeated for every member of the dataset to find the median.

The more variable an element is, the less important it is to the overall look or feel of your design. An example of this would be if there are several colors in your design, with one being very strong and lovable.
If you were to take away that color, your design would still work well because all of the other elements involved in making the theme successful exist. However, if you wanted to improve the aesthetic appeal of your design, you could add another layer of color by changing the coefficients of variance (or V’s) for each element.
The index of variability ($\eta$) calculates how spread out an element is within its area. A lower $\eta$ means that the element is closer to having a perfect circle shape, while higher V’s indicate larger squares or triangles.
Because we want our logos and designs to stick together as a whole, keeping some parts simple will help achieve that. By adding too many styles and features to a logo, it can become confusing who belongs where and why.