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_ImageZoomTranslateTableBlend(3MLIB)		    mediaLib Library Functions			  mlib_ImageZoomTranslateTableBlend(3MLIB)

NAME
mlib_ImageZoomTranslateTableBlend - image scaling using interpolation table, combined with alpha blending SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_ImageZoomTranslateTableBlend(mlib_image *dst, const mlib_image *src, mlib_d64 zoomx, mlib_d64 zoomy, mlib_d64 tx, mlib_d64 ty, const void *table, mlib_edge edge, mlib_blend blend, mlib_s32 cmask); DESCRIPTION
The mlib_ImageZoomTranslateTableBlend() function will enlarge or minify the source image by the X and Y zoom factors, with translation, and blend it with the destination image. It uses the following equation for coordinate mapping: xd = zoomx*xs + tx yd = zoomy*ys + ty where a point with coordinates (xs, ys) in the source image is mapped to a point with coordinates (xd, yd) in the destination image. The center of the upper-left corner pixel of an image is located at (0.5, 0.5). It is assumed that the overall alpha for controlling the blending between the source image and the destination image has been pre-multi- plied to the interpolation table for better performance. The alpha blending is closely combined with the interpolation to achieve better performance. Part of alpha blending has to be performed before or together with the interpolation if the source image has an alpha channel. In that case, the color components of each neighboring source pixel which participates in the interpolation (src_r and etc.) have to be pre-multiplied by the alpha component of the same source pixel (src_a). After the interpolation, the interpolated alpha (interp_a, which has been multiplied by the overall alpha because of the pre-multiplied interpolation table) and the destination pixel's original alpha (dst_a, if any) are used to blend the interpolated source pixel (with components interp_r and etc.) with the destination pixel (with components dst_r and etc.). The MLIB_BLEND_GTK_SRC blending is similar to the SRC rule of the Porter-Duff rules for image compositing. It is defined by Cd = Cs Ad = As in general, and by the following formula for this function: if (interp_a != 0.0) { if (dst_has_alpha) { dst_r = interp_r/interp_a; dst_g = interp_g/interp_a; dst_b = interp_b/interp_a; dst_a = interp_a; } else { dst_r = interp_r; dst_g = interp_g; dst_b = interp_b; dst_a = 1.0; // implied } } else { dst_r = 0; dst_g = 0; dst_b = 0; dst_a = 0; } The MLIB_BLEND_GTK_SRC_OVER or MLIB_BLEND_GTK_SRC_OVER2 blending is similar to the SRC_OVER rule of the Porter-Duff rules for image com- positing. It is defined by Cd = Cs + Cd*(1 - As) Ad = As + Ad*(1 - As) in general, and by the following formula for this function: w = interp_a + (1 - interp_a)*dst_a; if (w != 0.0) { dst_r = (interp_r + (1 - interp_a)*dst_a*dst_r)/w; dst_g = (interp_g + (1 - interp_a)*dst_a*dst_g)/w; dst_b = (interp_b + (1 - interp_a)*dst_a*dst_b)/w; dst_a = w; } else if (MLIB_BLEND_GTK_SRC_OVER) { dst_r = 0; dst_g = 0; dst_b = 0; dst_a = 0; } where src_a, interp_a and dst_a are assumed to be in the range of [0.0, 1.0]. For an image with 4 channels, the first or the fourth channel is considered the alpha channel if cmask equals 8 or 1, respectively. An image with 3 channels is considered to have no alpha channel, which is equivalent to having an alpha channel filled with all 1.0, or 0xff in case of MLIB_BYTE, if the general formulas for blending shown above are used. Both src and dst must be of type MLIB_BYTE. They can have either 3 or 4 channels. The src image cannot have width or height larger than 32767. PARAMETERS
The function takes the following arguments: dst Pointer to destination image. src Pointer to first source image. zoomx X zoom factor. zoomx > 0.0. zoomy Y zoom factor. zoomy > 0.0. tx X translation. ty Y translation. table Pointer to interpolation table structure. edge Type of edge condition. It can be one of the following: MLIB_EDGE_DST_NO_WRITE MLIB_EDGE_DST_FILL_ZERO MLIB_EDGE_OP_NEAREST MLIB_EDGE_SRC_EXTEND MLIB_EDGE_SRC_EXTEND_INDEF MLIB_EDGE_SRC_PADDED blend Type of alpha blending. It can be one of the following: MLIB_BLEND_GTK_SRC MLIB_BLEND_GTK_SRC_OVER MLIB_BLEND_GTK_SRC_OVER2 cmask Channel mask to indicate the alpha channel. RETURN VALUES
The function 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 |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_ImageZoomBlend(3MLIB), mlib_ImageZoomTranslateBlend(3MLIB), mlib_ImageInterpTableCreate(3MLIB), attributes(5) SunOS 5.10 10 Nov 2004 mlib_ImageZoomTranslateTableBlend(3MLIB)
All times are GMT -4. The time now is 10:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy