## Contents

- Example 1.1 - from MC submission 35194
- Example 1.2 - from MC submission 35194 with lower tolerance and more points
- Example 2.1 - gaussian pdf with randomly spaced points
- Example 2.2 - gaussian pdf with randomly spaced points and random noise
- Example 3.1 - digital sine wave with noise
- Example 3.2 - sine wave with normal random noise

%-------------------------------------------------------------------------- % EXAMPLES_reduce_interp_1d_linear.m % This runs through a number of examples demostrating the usage of the % function reduce_interp_1d_linear. Please see the documentation for % reduce_interp_1d_linear for more details on the inputs. This script has % also been published %-------------------------------------------------------------------------- % Author: Daniel R. Herber, Graduate Student, University of Illinois at % Urbana-Champaign % Date: 08/17/2015 %--------------------------------------------------------------------------

## Example 1.1 - from MC submission 35194

X = 0:0.1:10; Y = 1./(X/100 + 0.01) + X.^2 - 0.1 * X.^3; tol = 0.1; opts.interior_optflag = 1; % this is the default opts.post_optflag = 1; % this is the default opts.display_flag = 1; % this is the default [xi, yi] = reduce_interp_1d_linear(X,Y,tol,opts); % only uncomment if you have MC submission 35194 in your path % [xi35194, yi35194, mse35194] = find_best_table_1de(X, Y, [], tol, 'linear');

Original Data Length: 101 Finding reduced number of points maintaning error tolerance... ...Finished! Reduced Length: 34 with maximum absolute error of 0.099944 Percentage of original size: 33.6634% Mean Squared Error: 0.0011804 Solving approximate QP to minimize MSE... ...Finished! Percentage of Original Mean Squared Error : 61.8294% with maximum absolute error of 0.08205

## Example 1.2 - from MC submission 35194 with lower tolerance and more points

```
X = 0:0.0001:10;
Y = 1./(X/100 + 0.01) + X.^2 - 0.1 * X.^3;
[xi, yi] = reduce_interp_1d_linear(X,Y,0.01); % default options
```

Original Data Length: 100001 Finding reduced number of points maintaning error tolerance... ...Finished! Reduced Length: 103 with maximum absolute error of 0.0099379 Percentage of original size: 0.103% Mean Squared Error: 1.2441e-05 Solving approximate QP to minimize MSE... ...Finished! Percentage of Original Mean Squared Error : 45.7958% with maximum absolute error of 0.01

## Example 2.1 - gaussian pdf with randomly spaced points

X = cumsum(rand(1000,1)); X = 200*X/max(X); f1 = @(x,m,s) exp(-(x-m).^2/(2*s^2))/(s*sqrt(2*pi)); Y = f1(X,100,5) + f1(X,120,3) - f1(X,30,2); tol = 0.02*(max(Y)-min(Y)); % 2% maximum error [xi, yi] = reduce_interp_1d_linear(X,Y,tol); % default options

Original Data Length: 1000 Finding reduced number of points maintaning error tolerance... ...Finished! Reduced Length: 43 with maximum absolute error of 0.0065218 Percentage of original size: 4.3% Mean Squared Error: 1.515e-06 Solving approximate QP to minimize MSE... ...Finished! Percentage of Original Mean Squared Error : 41.7249% with maximum absolute error of 0.0055816

## Example 2.2 - gaussian pdf with randomly spaced points and random noise

X = cumsum(rand(1000,1)); X = 200*X/max(X); f1 = @(x,m,s) exp(-(x-m).^2/(2*s^2))/(s*sqrt(2*pi)); Y = f1(X,100,5) + f1(X,120,3) - f1(X,30,2) + rand(size(X))/200; tol = 0.02*(max(Y)-min(Y)); % 2% maximum error [xi, yi] = reduce_interp_1d_linear(X,Y,tol); % default options

Original Data Length: 1000 Finding reduced number of points maintaning error tolerance... ...Finished! Reduced Length: 45 with maximum absolute error of 0.00628 Percentage of original size: 4.5% Mean Squared Error: 3.1877e-06 Solving approximate QP to minimize MSE... ...Finished! Percentage of Original Mean Squared Error : 70.6773% with maximum absolute error of 0.0049842

## Example 3.1 - digital sine wave with noise

```
X = linspace(0,8,1000)';
F = round(15*sin(X));
Y = F + round(0.55*rand(size(X))) - round(0.55*rand(size(X))) ;
tol = 2;
[xi, yi] = reduce_interp_1d_linear(X,Y,tol); % default options
```

Original Data Length: 1000 Finding reduced number of points maintaning error tolerance... ...Finished! Reduced Length: 17 with maximum absolute error of 1.9281 Percentage of original size: 1.7% Mean Squared Error: 0.26834 Solving approximate QP to minimize MSE... ...Finished! Percentage of Original Mean Squared Error : 83.8737% with maximum absolute error of 1.6947

## Example 3.2 - sine wave with normal random noise

X = linspace(0,8,1e6)'; F = 15*sin(X); Y = F + randn(size(F))/2; tol = 2.5; opts.post_optflag = 0; % QP takes is large with 1e6 points [xi, yi] = reduce_interp_1d_linear(X,Y,tol,opts); % only uncomment if you have MC submission 35194 in your path % warning this will take a long time!! % [xi35194, yi35194, mse35194] = find_best_table_1de(X, Y, [], tol, 'linear');

Original Data Length: 1000000 Finding reduced number of points maintaning error tolerance... ...Finished! Reduced Length: 45 with maximum absolute error of 2.4845 Percentage of original size: 0.0045% Mean Squared Error: 0.28269