A strange formula


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting A strange formula
# 1  
Old 10-26-2013
A strange formula

Dear Masters,

Kindly need your helps for this issue..

I face a formula as a picture...

the input file is
Code:
    A DEPT        Vp           Vs            rho         VPperVS
 ------------------------ ------------ ------------ ------------
          700     151.9218     121.9269        2.223     3.623484
        700.5      155.016     125.0216        2.223     3.541452
          701      152.842     122.8473        2.223     3.581353
        701.5     154.3924      124.398        2.223     3.535076
          702     149.1104      119.116        2.223     3.649647
        702.5     140.8567      110.862        2.223     3.852324
          703     150.7773     120.7838        2.223     3.588501
        703.5     155.8877     125.8932        2.223     3.460893
          704     152.3356     122.3411        2.223      3.53136
        704.5     152.1419     122.1472        2.223     3.525742
          705     150.4891     120.4947        2.223     3.554218
        705.5      149.818     119.8241        2.223     3.558841
          706     162.8467     132.8524        2.223     3.263778
        706.5      152.063     122.0691        2.223     3.484347
          707     151.6896     121.6949        2.223     3.481663
        707.5     152.2395      122.245        2.223     3.458166
          708     151.4207     121.4262        2.223     3.465988
        708.5     151.9085     121.9141        2.223     3.444127
          709     150.7998      120.805        2.223     3.458545
        709.5      149.849     119.8546        2.223     3.469783
          710     148.9318     118.9373        2.223     3.485225
        710.5     146.2235     116.2287        2.223     3.603258
          711     144.8946     114.9012        2.223     3.701914
        711.5     130.9615      100.967        2.223     4.160463
          712     144.8977     114.9019        2.223      3.83023
        712.5     147.7456     117.7512        2.223     3.817976
          713     149.1007     119.1062        2.223     3.851385
        713.5     146.1146     116.1187        2.223      4.00504
          714     150.8179     120.8235        2.223     3.949459
        714.5     151.3544     121.3601        2.223     4.010254
          715     157.7299      127.733        2.223     3.918912
        715.5     136.3569     106.3686        2.223     4.469709
          716     172.2356      142.241        2.223     3.486321
        716.5     156.1267     126.1329        2.223     3.790136
          717     149.2792     119.2854        2.223     3.906321
        717.5     150.6867     120.6925        2.223     3.814899
          718     150.4559     120.4617        2.223      3.76809
        718.5     149.0493     119.0548        2.223     3.750639
          719     149.2419     119.2475        2.223     3.694633
        719.5     150.9317     120.9373        2.223     3.604242
          720     150.6643     120.6699        2.223     3.561953
        720.5     150.0267     120.0323        2.223     3.519127

the goal is we will get a new column (include angle information) from the highest correlation between VsperVs column and calculated output.
for this, in my logic is

1. run formula (describe in attached picture) for every angle (from -90 to 90)
2. correlate between formula output from step number one with VpperVs column
3. get the highest similarity
4. output the formula column (include angle information) which has the highest similarity

This issue is very hard for me, please kindly need your help..

Thanks and regards,
Ipatah
A strange formula-formulajpg
# 2  
Old 10-26-2013
Quote:
Originally Posted by ipatah
Dear Masters,

Kindly need your helps for this issue..

I face a formula as a picture...

the input file is
Code:
    A DEPT        Vp           Vs            rho         VPperVS
 ------------------------ ------------ ------------ ------------
          700     151.9218     121.9269        2.223     3.623484
        700.5      155.016     125.0216        2.223     3.541452
          701      152.842     122.8473        2.223     3.581353

the goal is we will get a new column (include angle information) from the highest correlation between VsperVs column and calculated output.
for this, in my logic is

1. run formula (describe in attached picture) for every angle (from -90 to 90)
2. correlate between formula output from step number one with VpperVs column
3. get the highest similarity
4. output the formula column (include angle information) which has the highest similarity

This issue is very hard for me, please kindly need your help..

Thanks and regards,
Ipatah
First you solve one or two records of your file by formula you provided using pen and paper and then let us know the expected output.
# 3  
Old 10-26-2013
Dear Akshay and Masters,

I can not do it in unix program, but i tried in excell (for 3 raws), please see my attached file.

thanks and regards,
Ipatah
# 4  
Old 10-26-2013
I don't see too many relations between your input table and the formula you presented. What is A DEPT? What is VPperVS (except it is mentioned that K=VPperVS squared)? Where is Theta defined? Where is Chi defined?
# 5  
Old 10-26-2013
Hi RudiC and Masters,

DEPT (should be DEPTH), it just shows where is data taken. VPperVS is taken from measurement, and it will be corelated with our calculated result or EEI (chi).
K is calculated by mean of (Vp/Vs)squared or (Vp/Vs)*(Vp/Vs).
Theta in EEI (θ) should be EEI (χ) or EEI (Chi) I think. χ or Chi are defined by angle (-90 to 90 degree).

So for every DEPTH we have have 180 calculated outputs (from -90 to 90 per 1 degree increment). Note : 180 calculated outputs are EEI(chi) in every angle (from -90 to 90 degree, 1 degree increment)

After we get 180 calculated outputs , these output will be correlated with VpperVs column, In excell file, correlation process need trend correlation, because the calculated output has difference value, example calculated output (in DEPTH 700) has 305.485 and VpperVs has 3.623484.

Here, I repair my formula and excell attachement.

Thanks for your reply and help..
Ipatah
# 6  
Old 10-27-2013
Try

Code:
$ cat file
    A DEPT        Vp           Vs            rho         VPperVS
 ------------------------ ------------ ------------ ------------
          700     151.9218     121.9269        2.223     3.623484
        700.5      155.016     125.0216        2.223     3.541452
          701      152.842     122.8473        2.223     3.581353

Code:
$ cat test.sh 
#!/bin/bash


awk  '
  NR>2{
            ++n
            vp+=$2; vs+=$3; rho+=$4;Vp_Vs+=($2/$3)^2
            for(i=1;i<=6;i++)A[n,i]=$i
      }

END{
        vpo  = vp/n
        vs0  = vs/n
        rho0 = rho/n
        k    = Vp_Vs/n
    
        printf "Angle" OFS "p" OFS "q" OFS "r" OFS
        for(x=1;x<=n;x++)printf A[x,1] OFS;printf "\n"

for(j=-90;j<=90;j++){
                             p=cos(j)+sin(j)
                             q=-8*k*sin(j)
                             r=cos(j)-(4*k*sin(j))
                             printf j OFS p OFS q OFS r OFS 

           for(i=1;i<=n;i++){
                                   EEI=vpo*rho0*((A[i,2]/vpo)^p) * ((A[i,3]/vs0)^q) * ((A[i,4]/rho0)^r)
                                   printf EEI OFS 
                            }
                                  printf "\n"
                    }

   }' OFS="\t" CONVFMT="%5.3f" OFMT="%.2g" file

Resulting

Code:
$ bash test.sh   
Angle p q r 700 700.5 701 -90 -1.342 11.057 5.080 305.533 392.341 329.344 -89 -0.350 10.637 5.829 304.277 394.452 328.922 -88 0.964 0.438 1.218 336.218 346.599 339.296 -87 1.392 -10.164 -4.512 376.060 299.780 351.326 -86 0.540 -11.421 -6.094 384.115 291.652 353.651 ................................................................. ................................................................. ................................................................. ................................................................. ................................................................. 88 1.035 -0.438 0.780 339.237 342.608 340.241 89 1.370 -10.637 -4.808 378.078 297.708 351.912 90 0.446 -11.057 -5.976 382.905 292.846 353.304

to save $ bash test.sh >test_file.xlsand in text import wizard select tab for separator

Let me know if its helpful for you

Last edited by Akshay Hegde; 10-27-2013 at 05:06 AM.. Reason: format
This User Gave Thanks to Akshay Hegde For This Post:
# 7  
Old 10-28-2013
Hi Askhay and Masters,

Thank for your help.. For cross correlation process, could we use Askhay's output and the formula in attached file to get "correl for angle" value. Kindly need your helps..

thanks and regards,
Ipatah
A strange formula-secondformulajpg

Last edited by ipatah; 10-28-2013 at 12:00 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Formula calculate scan rate

Hi There, Just curious here... If there formula to calculate scan rate on solaris? Thanks Edy (3 Replies)
Discussion started by: edydsuranta
3 Replies

2. Shell Programming and Scripting

Formula missing in excel after using perl

Hi all, I use "Spreadsheet::ParseExcel::SaveParser" to - read a existing excel file with : $Parser = Spreadsheet::ParseExcel::SaveParser->new(); $HeaderFile = $Parser->Parse("XLS_FILE_ACCESS"); - modify some values in somes cell with : $worksheet->AddCell($row_target,$col_max,... (3 Replies)
Discussion started by: Yom
3 Replies

3. Shell Programming and Scripting

formula missing in excel after using perl

Dear all, I got a template excel file which contains several worksheets. Each worksheet contains some formulas in the cells. I am using the perl script to read a CSV file and then put the data of CSV into template excel file(first worksheet) and then save it as new file name using ... (0 Replies)
Discussion started by: eldonlck
0 Replies

4. Shell Programming and Scripting

Convert Formula to Value

I'm new to Perl, but I need to use it to write into an excel spreadsheet. I want to copy the values of certain cells into a new sheet in the workbook. I'm unsure of how to do this because I don't know how to copy values instead of formulas. Note: by formula I mean '=SUM(A1,A2)' and by value I... (0 Replies)
Discussion started by: AgentSmith88
0 Replies

5. Shell Programming and Scripting

Formula to get combinationů sum

Formula to get combination Lats say, I have 5 values ID Price 1 5 2 10 3 30 4 5 Resule with Possible combinations will be ID Price 1 5 2 10 3 30 4 5 1+1 10 1+2 15 1+3 35 1+4 10 (1 Reply)
Discussion started by: Amit.Sagpariya
1 Replies

6. Shell Programming and Scripting

how to create script for this formula?

Hello Unix gurus, Can anyone tell me the most efficient way to create script for the formula? Formula: Ans = 1 - ((Buffer pool data physical reads + Buffer pool xda physical reads + Buffer pool index physical reads + Buffer pool temporary data physical reads + Buffer pool temporary xda... (6 Replies)
Discussion started by: Rahulpict
6 Replies

7. UNIX for Dummies Questions & Answers

Formula help

The formula below will calculate a distance in miles between 2 points in excel. Can some put it to work in unix? Lat = 43.335 Lon1 = -70.9884 Lat2 = 43.4829 Lon2 = -71.246 distance... (8 Replies)
Discussion started by: bobo
8 Replies

8. Solaris

formula to get the swap space on a machine

Hello there are different opinions on how to get the swap space on Solaris. some say: swap -s and the space= used + available others say swap -l (donno how they get the swap size) other say 'top' command others say using format command (in print sub-command) Could you please advise on... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

9. Shell Programming and Scripting

Help with formula in a script

I need some help. I been doing system admin for the last several years and gotten very rusty on scripting. I need to write a script that will take a log entry and do math using two columns of data to create a new column. I am taking the column(#2) that contains the time and the column(#5) that... (3 Replies)
Discussion started by: scottzx7rr
3 Replies

10. UNIX for Advanced & Expert Users

Quadratic Formula Program

I have a question about the program I am making. I finished it, compiled it, and there were no errors. Now when I run it, the comand prompt comes up and there are just 1's and 0's that keep looping over and over again. The program is listed before. If anyone has any suggestions I would greatly... (2 Replies)
Discussion started by: zeek
2 Replies
Login or Register to Ask a Question