Pendant Pendant Sum Handedness


1. HANDEDNESS of Pendant Pendant Sums:

Code
#=======================================================
# INITIALIZE
# Read in the Fieldmark and its associated dataframes
#=======================================================
import statistics
import pandas as pd
import plotly as plotly
import plotly.express as px
import qollqa_chuspa as qc  
import utils_khipu as ukhipu

from fieldmark_ascher_pendant_pendant_sum import FieldmarkPendantPendantSum
aFieldmark = FieldmarkPendantPendantSum()
khipu_df = aFieldmark.dataframes[0].dataframe
sum_cord_df = aFieldmark.dataframes[1].dataframe

(khipu_dict, all_khipus) = qc.fetch_khipus()

# Initialize plotly
plotly.offline.init_notebook_mode(connected = False);

2. The Direction of Sums:

Code
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [30, 10]
sum_cord_df.hist()
array([[<Axes: title={'center': 'Unnamed: 0'}>,
        <Axes: title={'center': 'cord_value'}>],
       [<Axes: title={'center': 'num_summands'}>,
        <Axes: title={'center': 'handedness'}>]], dtype=object)

Code
from statistics import mean, stdev

num_right_handed_sums = khipu_df['num_right_sums'].sum()
num_left_handed_sums = khipu_df['num_left_sums'].sum()
right_ratio = 100.0*float(num_right_handed_sums)/float(num_right_handed_sums + num_left_handed_sums)
left_ratio = 100.0*float(num_left_handed_sums)/float(num_right_handed_sums + num_left_handed_sums)
print(f"There are a total of {len(sum_cord_df)} Pendant Pendant Sums")
print(f"    {num_right_handed_sums} ({right_ratio:.0f}%) are Right-handed sums and {num_left_handed_sums} ({left_ratio:.0f}%) are Left-handed sums") 

right_handed_sums_df = sum_cord_df[sum_cord_df.handedness >= 0]
left_handed_sums_df = sum_cord_df[sum_cord_df.handedness < 0]
right_handed_sums = right_handed_sums_df.cord_value.values.tolist()
left_handed_sums = left_handed_sums_df.cord_value.values.tolist()
print(f"    Right Sums: Range=({min(right_handed_sums)},{max(right_handed_sums)}), Mean={mean(right_handed_sums):.0f}, Std_dev={stdev(right_handed_sums):.0f}")
print(f"    Left Sums: Range=({min(left_handed_sums)},{max(left_handed_sums)}), Mean={mean(left_handed_sums):.0f}, Std_dev={stdev(left_handed_sums):.0f}")
There are a total of 6443 Pendant Pendant Sums
    3505 (54%) are Right-handed sums and 2938 (46%) are Left-handed sums
    Right Sums: Range=(11,6034), Mean=133, Std_dev=340
    Left Sums: Range=(11,6569), Mean=123, Std_dev=315

One of the surprising things about searching for all sums, was the realization that sums could be sums of cords before them (i.e. left-handed), or after them (i.e. right handed).

Being Indo-European writers and readers, we assume that

    Y0 = x1 + x2 + … + xn.

In khipu, the equations go both ways and we can also have

    x0 + x1 + … + xm = Yn

We can “measure” the handedness of a pendant sum by evaluating the distance between the sum cord and the summands cords:

    handedness = mean(summand_cluster_cords_positions) - sum_cluster_position

This gives left-handed sums a negative handedness, and right-handed ones, a positive….

You can see that from the above snapshot, that there’s a 60/40 ratio of right-handed to left-handed sums. Considering that left-handed sums are only 2/3 as frequent, they have (roughly) the same magnitudes, means, and standard deviations of right-handed sums. This is roughly illustrated in the histogram of handedness color above. However, when you look at the histogram for handedness, it does not appear that way. What gives? The answer is that the histogram of handedness is really “like a moment arm”, and the heavy moment arms of the few but significant sum relationships barely show in the histogram.

2.1 by Handedness

Code
khipu_df = aFieldmark.dataframes[0].dataframe

sum_cord_df = aFieldmark.dataframes[1].dataframe
def handed_color(x): return 0.0 if x < 0 else 1.0
sum_cord_df['handed_color'] = [handed_color(x) for x in sum_cord_df.handedness.values]

handedness_mean = mean(list(sum_cord_df.handedness.values))
legend_text = "<i style=\"font-size:10pt;\">&nbsp;&nbsp;Size:Num Summand Cords, Red:Right-handed, Blue:Left-handed" + \
              " - Hover Over Circles to View Khipu/Cord Info</i>"
fig = (px.scatter(sum_cord_df, x="handedness", y="cord_value", log_y=True,
                 size="num_summands", 
                 color='handed_color', color_continuous_scale=['#3c3fff', '#ff3030',],
                 labels={"handedness": f"Handedness - Mean({handedness_mean})", "cord_value": "Cord Value (Log(y) scale)", },
                 hover_data=['handedness'], title=f"<b>Handeness of Pendant Pendant Sums</b>{legend_text}",
                 width=944, height=944)
        .update_layout(showlegend=False).update(layout_coloraxis_showscale=False).show()
      )

This handedness of pendant sum matching is intriguing in it’s symmetry (right down to a left and right hand for AS069 around 500 and 535! There are a lot of small dots on horizontal lines at cord-values of 100, 10,9,8…5. These are a lot of 0’s plus the value and in general any horizontal line of dots in the above graph is probably noise.

Code
legend_text = "<b>Handedness Frequency by Sum</b>"
fig = (px.violin(sum_cord_df, y="handedness",  
                 points='all',
                 hover_data=['kfg_name', 'cord_index', 'num_summands', 'handedness'], title=legend_text,
                 width=944, height=944).show())

Plotting the sums by handedness shows the greater presence of right-handed sums (>=0) vs left-handed sums (< 0). It also shows, as one might expect that left-handed sums are closer together (ie. have less overall handedness), than right-handed sums.

2.2 by Sum/Cord-Value

Code
from statistics import median
right_handed_mean = mean(list(sum_cord_df[sum_cord_df.handedness >= 0.0].cord_value.values))
left_handed_mean = mean(list(sum_cord_df[sum_cord_df.handedness < 0.0].cord_value.values))
legend_text = "<i style=\"font-size:10pt;\">&nbsp;&nbsp;Size:Sum Cord Value, Red:Right-handed, Blue:Left-handed - " + \
              "Hover to View Khipu/Cord Info</i>"
fig = (px.scatter(sum_cord_df, x="num_summands", y="cord_value", log_y=True,
                  size="cord_value", 
                  color='handed_color', color_continuous_scale=['#3c3fff', '#ff3030',],
                  labels={"num_summands": "Number of contiguous cords in sum", "cord_value": "Sum Cord Value (Log(y) scale)"},
                  hover_name='kfg_name', hover_data=['cord_value', 'num_summands'], 
                  title=f"<b>Pendant Sums of Pendants</b>{legend_text}",
                  width=944, height=944)
        #.add_hline(y=right_handed_mean, line_color='Red')
        #.add_hline(y=left_handed_mean, line_color='Blue')
        .update_layout(showlegend=False).update(layout_coloraxis_showscale=False).show()
      )

The number of summands is proportional to the sum value, as expected. However, both left and right handed sums have similar orders of magnitude, their actual ranges differ, as we see.

2.3 Range Cord Value

What is the range of handed cord values?

Code
right_sum_cord_position_df = sum_cord_df[sum_cord_df.handedness >= 0]
left_sum_cord_position_df = sum_cord_df[sum_cord_df.handedness < 0]
max_right_cord_value = max(list(right_sum_cord_position_df.cord_value.values))
max_left_cord_value = max(list(left_sum_cord_position_df.cord_value.values))
print(f"Maximum Right-Handedness Sum Cord Value is {max_right_cord_value}, Maximum Left-Handedness Sum Cord Value is {max_left_cord_value}")
Maximum Right-Handedness Sum Cord Value is 6034, Maximum Left-Handedness Sum Cord Value is 6569

Of the top 10 mean cord value khipus, how many of them have pendant-pendant-sum relationships?

Code
khipu_summary_df = pd.read_csv(f"{ukhipu.fieldmarks_data_directory()}/CSV/khipu_summary.csv")
matching_khipus = list(khipu_summary_df.sort_values(by='mean_cord_value', ascending=False).kfg_name.values)
def khipu_mean_cord_value(khipu_name):
    khipu_df = khipu_summary_df[khipu_summary_df.kfg_name==khipu_name]
    return list(khipu_df.mean_cord_value.values)[0]
def num_sum_relations(aKhipuName, aSumDF):
    return len(aSumDF[aSumDF.kfg_name == aKhipuName])
def calc_relation_counts(khipu_list, relation_df, is_right_handed=True):
    relations_counts = [(khipuName, khipu_mean_cord_value(khipuName), num_sum_relations(khipuName, relation_df)) for khipuName in khipu_list]
    count_df = pd.DataFrame(relations_counts, columns = ['KhipuName', 'MeanCordValue', 'NumSums'])
    return count_df
relations_count_df = calc_relation_counts(matching_khipus, sum_cord_df)
handedness_mean = round(statistics.mean(relations_count_df['MeanCordValue'].values.tolist()))
Code
legend_text = f"<i style=\"font-size:10pt;\">&nbsp;Mean={handedness_mean} &nbsp;&nbsp;Hover Over Circles to View Khipu/Cord Info</i>"
fig = (px.scatter(relations_count_df, x="MeanCordValue", y="NumSums", log_x=True, 
                  labels={"NumSums": "Number of Sum Relationships", "cord_value": "Khipu's Mean Cord Value (Log(y) scale)"},
                  hover_name='KhipuName', hover_data=['MeanCordValue', 'NumSums'], 
                  title=f"<b>Pendant Pendants Sums by Log(Cord Value)</b>{legend_text}",
                  width=944, height=944)
        .add_vline(x=handedness_mean, line_color='Red')
        .update_traces(marker=dict(color='Black'))
        .update_layout(showlegend=False).update(layout_coloraxis_showscale=False).show()
      )

American writer Scott Fitzgerald is supposed to have said to Ernest Hemingway, ‘You know, the rich really are different from you and me.’ Hemingway’s reply: ‘Yes. They’ve got more money.’ Khipus with large cord values, really are in a class by themselves. They have few sum relationships and are less a working man’s khipu and more of an “executive summary.” There seems to be sweet spot where pendant-pendant sums occur, sum-where between mean-cord values of 10 and a 1000.

3. Conclusions:

There are a total of 6443 Pendant Pendant Sums 3505 (54%) are Right-handed sums and 2938 (46%) are Left-handed sums Right Sums: Range=(11,6034), Mean=133, Std_dev=340 Left Sums: Range=(11,6569), Mean=123, Std_dev=315

CASE STUDIES:

The following groups of khipus have interesting commonalities:

  • AS068, UR281, UR277 have 41 summands
  • UR1149, AS050, UR281, UR197 all have cord values around 5000
  • UR217, AS008, UR2881, UR1095 all have cord values around 2000
  • AS068 is the poster child of sum relationships