Sponsored Content
Full Discussion: Calculate Beta or Slope !
Top Forums Shell Programming and Scripting Calculate Beta or Slope ! Post 302707595 by elixir_sinari on Saturday 29th of September 2012 04:33:38 AM
Old 09-29-2012
Code:
cat testfile
04/09/2012      140.28          31.36
05/09/2012      140.16          31.27
06/09/2012      143.01          31.67
07/09/2012      143.56          32.64
10/09/2012      142.75          32.29
11/09/2012      143.15          32.41
12/09/2012      143.62          32.21
13/09/2012      145.81          33.61
14/09/2012      146.46           33.6
17/09/2012      145.96          32.99
18/09/2012      145.84          33.71
19/09/2012      145.92          33.57
20/09/2012      145.93          33.58
21/09/2012      145.87          33.48
24/09/2012      145.65          32.93
25/09/2012      144.1           32.68
26/09/2012      143.29          32.87
27/09/2012      144.64          33.58
28/09/2012      143.97          33.48

awk 'NR!=1{perc1[++i]=(($2-prev1)/$2)*100
perc2[i]=(($3-prev2)/$3)*100
sum1+=perc1[i]
sum2+=perc2[i]
max=i}
{prev1=$2;prev2=$3}
END{
avg1=sum1/max
avg2=sum2/max
for(i=1;i<=max;i++)
{
 numsum+=((perc1[i]-avg1)*(perc2[i]-avg2))
 densum+=((perc2[i]-avg2)**2)
}
print "Slope : " numsum/densum
}' testfile
Slope : 0.293058

 

We Also Found This Discussion For You

1. Shell Programming and Scripting

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... (10 Replies)
Discussion started by: worm
10 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 10:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy