## Calculate ratios for each pair in a given file

Calculate ratios for each pair in a given file
# 1
Calculate ratios for each pair in a given file

Hello,
My input file looks like this
I need to calculate the average fraction of 'ID' that are identical, averaged across all possible pairings (Individual1,Individual2), (Individual1,Individual3), (Individual1,Individual4),

The formula to calculate this is as below

For example for for ID1, the values for (Individual1,Individual2) are (0|1,0|1)so the ratio will be calculated as such
For ID15 This is averaged over all ID, and reported for all pairs of individuals. In this file, I have over 2000 IDs and several individuals and am currently doing it in excel. Is this possible to code this formula in bash or python at all to accept a text tab delimited file ?

The output I am looking for is such

Last edited by Scrutinizer; 07-03-2019 at 12:05 PM.. Reason: quote tags -> code tags
 nans View Public Profile for nans Find all posts by nans

Test Your Knowledge in Computers #983
Difficulty: Medium
The first official NetBSD release, NetBSD 0.1, was made on 9 April 1991.
True or False?

## Parsing a name Value pair file

Hi, I have a file having rows as Row1 : model=.1.3.6.1.4.1.9.1.1047,location=abc, pollgrp=PG_CISCO4, ifindex=3, ip=10.10.10.1,parttype=Interface, devtype=Router,part=GigabitEthernet0/1,ifmtu=1520 Row2 :...

## Deleting a file with no corresponding pair

Hi, I am working with 2 sets of files (*csv and *asc) and I wanted to delete asc file with no corresponding csv counterpart. I did tried it manually but its been difficult working with a longer list of files. sample files in directory 20120601.csv 20120601_f1.asc 20120603.csv 20120602_f1.asc...

## Sort files as pair file

Hello, I am wondering if there is a way to sort file in directory by pair name : I am looking to get the extension .txt above the .archlike this if possible liste_NATIVE_HINDCAST_PSY1V2R2_R20120314.txt flag.NATIVE_HINDCAST_PSY1V2R2.R20120314.arch...

## Parsing with Name value pair and creating a normalized file

I have url string as follows and I need to parse the name value pair into fields /rows event_id date time payload 1329130951 20120214 22.30.40...

## Compression ratios of .tbz file

Hi, I have a question about finding the compression ratios of a zip (bzip2) file.I have written a procedure which upon certain criteria tar's and bzip2 certain directories and moves them to a near line storage. Yesterday I happened to stumble upon it. The procedure has tared and bzipped 6...

## Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do...

## Parse file from remote server to calculate count of string existence in that file

Hi I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files. Say a file abc.log exist on 2 servers. I want to search for string "test" on both files and calculate the total count of search string's existence. For...

## Calculate the time difference between a local file and a remote file.

I m stuck with a issue. I need to calculate the time difference between two files.. one on the local machine and one on the remote machine using a script. Can any one suggest the way this can be achevied Thanks, manohar