turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- How to resample / interpolate unevenly spaced time...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 10, 2015 3:58 AM
(1322 views)

2 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 12, 2015 12:07 PM
(990 views)

The answer to your question depends on how irregular your x values are, and what, precisely, you mean by 'interpolate'.

So the script below is definitely not a recommendation, just an example of the kind of thing that's possible. If you don't need a script, you should be able to follow similar steps manually.

Probably, though, the important question is what will you use the final values for?

NamesDefaultToHere**(****1****)**;

// (0) Make some evenly spaced data using a particular function

h = Function**(** **{**x**}**, **{**Default Local**}**, **0.5** + **0.4** * Sin**(** **2** * Pi**()** * x **)** **)**;

N = **100**; // Number of (equally-spaced) x values in [0,1]

xVals = Index**(** **0**, **1**, **1** / **(**N - **1****)** **)**`; // x values as a column vector

yVals = h**(** xVals **)** + J**(** N, **1**, Random Normal**(** **0**, **0.1** **)** **)**; // y values as a column vector

// (1) Randomly decimate three quarters the data to simulate uneven x values (but still on the original grid)

del = RandomIndex**(**N, Round**(****3***N/**4**, **0****))**;

xVals**[**del**]** = **[]**;

yVals**[**del**]** = **[]**;

dt = NewTable**(**"Uneven x",

NewColumn**(**"x", Numeric, Continuous, Values**(**xVals**))**,

NewColumn**(**"y", Numeric, Continuous, Values**(**yVals**))**

**)**;

// (2) Fit a kernel smoother and save the prediction formula

biv = dt << **Bivariate****(** Y**(** :y **)**, X**(** :x **)** **)**;

biv << **Kernel Smoother****(** **1**, **1**, **0.48261**, **0**, **{**Save Prediction Formula**})**;

// (3) Get the prerdiction formula

pForm = Column**(**dt, "Loess Predictor for y"**)** << **getProperty****(**"Formula"**)**;

// (4) Build a new table to hold equally-spaced x values

CMD = Expr**(**

dt2 = NewTable**(**"Even x",

NewColumn**(**"x", Numeric, Continuous**)**,

NewColumn**(**"Predicted y", Numeric, Continuous, Formula**(**TBD**))**

**)**

**)**;

SubstituteInto**(**CMD, Expr**(**TBD**)**, EvalExpr**(**pForm**))**;

CMD;

// (5) Get the simulated measured data into two vectors

xVals = Column**(**dt, "x"**)** << **GetAsMatrix**;

yVals = Column**(**dt, "y"**)** << **GetAsMatrix**;

// (6) Find the smallest x increment in the data

xDel = Min**(**xVals**[****2**::NRow**(**xVals**)]** - xVals**[****1**::**(**NRow**(**xVals**)**-**1****)])**;

// (7) Fill the table with the interpolated data using an equal spacing of, say 3*xDel

xVals2 = Index**(** **0**, **1**, **3***xDel **)**`;

Column**(**dt2, "x"**)** << **SetValues****(**xVals2**)**;

// (8) Look at the result

dt2 << **Graph Builder****(**

Size**(** **534**, **454** **)**,

Show Control Panel**(** **0** **)**,

Variables**(** X**(** :x **)**, Y**(** :Predicted y **)** **)**,

Elements**(** Points**(** X, Y, Legend**(** **5** **)** **)** **)**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 16, 2015 7:33 AM
(990 views)