Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Computing for linearly-interpolated values using awk Post 302757935 by ida1215 on Friday 18th of January 2013 08:12:27 AM
Old 01-18-2013
Computing for linearly-interpolated values using awk

Hi,

I want to compute for linearly-interpolated values for my data using awk, any help is highly appreciated.

How do I apply the linear interpolation formula to my data in awk given the equation below:
Code:
x   y
15  0
25  0.1633611
35  0.0741623

desired output: linear interpolation at 0.1 interval
x        y_interpolated
15       0
15.1     0.001633611
15.2     0.003267222
15.3 ..  0.004900833 
24.9     0.161727489
25       0.1633611

the interpolated values (yn) were calculated using the ff. equation

y_n=((x_n-x_1)*(y_2 - y_1)/x_2 - x_1) + y_1

y_15.1=((15.1-15)*(0.1633611-0)/25-15)/0

Thank you very much.
 

8 More Discussions You Might Find Interesting

1. Virtualization and Cloud Computing

Event Cloud Computing - IBM Turning Data Centers Into ?Computing Cloud?

Tim Bass Thu, 15 Nov 2007 23:55:07 +0000 *I predict we may experience less*debates*on the use of the term “event cloud”*related to*CEP in the future, now that both IBM and Google* have made announcements about “cloud computing” and “computing cloud”, IBM Turning Data Centers Into ‘Computing... (0 Replies)
Discussion started by: Linux Bot
0 Replies

2. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies

3. Shell Programming and Scripting

Computing data in awk

Hello, I am a newbie in programing. I want to compute the following in awk. I have the following data file: ID Value1 Value2 Value3 sade 0.21 0.45 23 foly 0.31 0.34 43 jude 0.40 0.11 63 jude 0.53 0.32 34 sade 0.67 0.49 66 foly 0.30 0.20 56 I want to take an ID “sade” , then take its... (6 Replies)
Discussion started by: ubeejani
6 Replies

4. Shell Programming and Scripting

AWK: read values from file1; search for values in file2

I have read another post about this issue and am wondering how to adapt it to my own, much simpler, issue. I have a file of user IDs like so: 333333 321321 546465 ...etc I need to take each number and use it to print records wherein the 5th field matches the user ID pulled from the... (2 Replies)
Discussion started by: Bubnoff
2 Replies

5. Shell Programming and Scripting

Computing average values from multiple text files

Hi, first, I have searched in the forum for this, but I could not find the right answer. (There were some similar threads, but I was not sure how to adapt the ideas.) Anyway, I have a quite natural problem: Given are several text files. All files contain the same number of lines and the same... (3 Replies)
Discussion started by: rbredereck
3 Replies

6. Shell Programming and Scripting

Computing the ratio of similar columns in the two files using awk script

Thanks Bartus11 for your help in the following code to compare the two files "t1" and "t2". awk 'NR==FNR{a=1;next}$2 in a{print $2}' t1 t2 First can anyone explain that what is the purpose of assigning a =1? Second, the current script is printing out the matched columns between the... (4 Replies)
Discussion started by: coder83
4 Replies

7. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

8. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies
mlib_VolumeRayCast_Blocked(3MLIB)			    mediaLib Library Functions				 mlib_VolumeRayCast_Blocked(3MLIB)

NAME
mlib_VolumeRayCast_Blocked, mlib_VolumeRayCast_Blocked_Parallel_Nearest_U8_U8, mlib_VolumeRayCast_Blocked_Parallel_Nearest_S16_S16, mlib_VolumeRayCast_Blocked_Parallel_Trilinear_U8_U8, mlib_VolumeRayCast_Blocked_Parallel_Trilinear_S16_S16, mlib_VolumeRay- Cast_Blocked_Divergent_Nearest_U8_U8, mlib_VolumeRayCast_Blocked_Divergent_Nearest_S16_S16, mlib_VolumeRayCast_Blocked_Divergent_Trilin- ear_U8_U8, mlib_VolumeRayCast_Blocked_Divergent_Trilinear_S16_S16 - cast a ray (or rays) through a 3D data set SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_VolumeRayCast_Blocked_Parallel_Nearest_U8_U8 (mlib_rays *rays, const mlib_blkvolume *blk, void *buffer); mlib_status mlib_VolumeRayCast_Blocked_Parallel_Nearest_S16_S16 (mlib_rays *rays, const mlib_blkvolume *blk, void *buffer); mlib_status mlib_VolumeRayCast_Blocked_Parallel_Trilinear_U8_U8 (mlib_rays *rays, const mlib_blkvolume *blk, void *buffer); mlib_status mlib_VolumeRayCast_Blocked_Parallel_Trilinear_S16_S16 (mlib_rays *rays const mlib_blkvolume *blk, void *buffer); mlib_status mlib_VolumeRayCast_Blocked_Divergent_Nearest_U8_U8 (mlib_rays *rays, const mlib_blkvolume *blk, void *buffer); mlib_status mlib_VolumeRayCast_Blocked_Divergent_Nearest_S16_S16 (mlib_rays *rays, const mlib_blkvolume *blk, void *buffer); mlib_status mlib_VolumeRayCast_Blocked_Divergent_Trilinear_U8_U8 (mlib_rays *rays, const mlib_blkvolume *blk, void *buffer); mlib_status mlib_VolumeRayCast_Blocked_Divergent_Trilinear_S16_S16 (mlib_rays *rays, const mlib_blkvolume *blk, void *buffer); DESCRIPTION
Each of these functions casts a ray (or rays) through a three-dimensional(3D) data set, then computes and returns the interpolated samples at each step along the way. In trilinear interpolation, the value at point P is computed from its eight surrounding neighbors based on the equation below. P = (1-a)*(1-b)*(1-c)*P0 + a*(1-b)*(1-c)*Px + (1-a)*b*(1-c)*Py + (1-a)*(1-b)*c*Pz + a*b*(1-c)*Pxy + a*(1-b)*c*Pxz + (1-a)*b*c*Pyz + a*b*c*Pxyz where a, b, and c are the fractional parts of the coordinates of point P. The trilinear interpolation is represented by the following figure: Printed copy or docs.sun.com displays a figure that represents the trilinear interpolation. In nearest neighbor operation, the sample value at point P is replaced by the value of the nearest neighbor voxel. PARAMETERS
Each of the functions takes the following arguments: rays Casting rays. blk Volume data in the blocked format. buffer Working buffer. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_VolumeRayCast_General(3MLIB), attributes(5) SunOS 5.11 2 Mar 2007 mlib_VolumeRayCast_Blocked(3MLIB)
All times are GMT -4. The time now is 03:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy