## Help with identify gradient and the coefficient of determination of a straight line

Help with identify gradient and the coefficient of determination of a straight line
# 8
04-03-2014
I can help you digest it. I honestly meant to explain every solution that I post on this site.

Most of the stuff before "if (denomy != 0)" are just variables that are used to calculate the slopes and R squared values. I'm specifically talking about the first five sets of curly brackets. There are also several integers in the formulas that are fixed. 19 is the sum of the x values, 145 is the sum of the squares of the x values, 361 is the square of the sum of the x values and 4 is the number of data points you have (I use 4.0 to avoid integer division--I'm not sure if that's necessary). We check if denomy is equal to zero because it's the only thing responsible for division by zero and thus the #N/A. If denomy is not equal to zero, then we print the original file (that's what \$0 means, and by the way, \$1 means first field, \$2 means second field and so on), then we print the slope, and then the R squared value. If denomy is zero, we do the same as if it weren't, except we don't print R squared, we just print "#N/A". You could put anything in place of "#N/A" that you want. Let me know if you have any questions.
This User Gave Thanks to blakeoft For This Post:
 blakeoft View Public Profile for blakeoft Find all posts by blakeoft
# 9
04-08-2014
Thanks, blakeoft.

Your explanation in detail really help me a lot.
I'm very appreciate for that

Currently I'm trying to edit the code if I have more data column information add in.
Thanks first.
 perl_beginner View Public Profile for perl_beginner Find all posts by perl_beginner
# 10
04-09-2014
Hi blakeoft,

Sorry for disturbing again.
Do you have any idea calculate only those fixed number in your awk code based on case by case ?
I have 80,000++ line in an input file. I would like to calculate slope and R2 of each line based on their corresponding column data.

Really thanks if you have any idea.
 perl_beginner View Public Profile for perl_beginner Find all posts by perl_beginner
# 11
04-10-2014
I'm not quite sure I understand your question. Are you wanting to be able to find the slope and R squared for each row if the x values aren't always 0, 3, 6 and 10?
 blakeoft View Public Profile for blakeoft Find all posts by blakeoft

## awk to identify empty fields in line

I am trying to use awk to identify and print out records in fields that are empty along with which line they are in. I hope the awk below is close, it runs but nothing results. Thank you :). awk awk -F'\t' 'FNR==NR ~ /^*\$/ { print "NR is empty" }' file file 123 GOOD ID 45...

## Regex to identify word in second position on a line

I am interested in finding a regex to find a word in second position on a line. The word in question is या I tried the following PERL EXPRESSION but it did not work: ] या or ^\W या But both gave Null results I am giving below a Sample file: देना या सौंपना=delegate तह जमना या...

## Determination n points between two coordinates

Hi guys. Can anyone tell me how to determine points between two coardinates. For example: Which type of command line gives me 50 points between (8, -5, 7) and (2, 6, 9) points Thanks

## correlation coefficient - Awk

Hi guys I have an input file with multiple columns and and rows. Is it possible to calculate correlation of certain value of certain No (For example x of S1 = 112) with all other values (for example start with x 112 corr a 3 of S1 = x-a 0.2 ) INPUT ******* No S1 S2 S3 S4 Sn a 3 ...

## plotting a straight horizontal line

How can I plot a straight horizontal line using perl in unix solaris environment? Please suggest. Pooja

## mth code determination

FILE_DATE=`date +%Y%m%d` current mth code is 200808 How can i find the 56 mths back mth code.

## Need to identify the line containing @ in between the line of a file

Hi All, I have a huge unix flat file delimted by @ at the end of the line. I need to find out if there is any line/s containing @ in between the line so that I can remove that and put the file for processing. Thanks in advance for your help.

## Identify duplicate words in a line using command

Hi, Let me explain the problem clearly: Let the entries in my file be: lion,tiger,bear apple,mango,orange,apple,grape unix,windows,solaris,windows,linux red,blue,green,yellow orange,maroon,pink,violet,orange,pink Can we detect the lines in which one of the words(separated by field...

## Telnet client IP determination

I have configured my firewall to allow only five remote IP's to connect to my server. Upon connection...i would like to automate the Xsession functions for authorized IP's. Mainly, \$DISPLAY of the environment to the client. I understand that the "gethostbyaddr" function is capable of this....

## Hardware Determination

Does anyone know an equiv of lscfg -vp for HP-UX?