function MCresult = debn_create_dataset(varargin)
%DEBN_CREATE_DATASET  One line description goes here.
%
%   More detailed description goes here.
%
%   Syntax:
%   varargout = debn_create_dataset(varargin)
%
%   Input:
%   varargin  =
%
%   Output:
%   varargout =
%
%   Example
%   debn_create_dataset
%
%   See also 

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2012 Delft University of Technology
%       Kees den Heijer
%
%       C.denHeijer@TUDelft.nl	
%
%       Faculty of Civil Engineering and Geosciences
%       P.O. Box 5048
%       2600 GA Delft
%       The Netherlands
%
%   This library is free software: you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation, either version 3 of the License, or
%   (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You should have received a copy of the GNU General Public License
%   along with this library.  If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------

% This tool is part of <a href="http://www.OpenEarth.eu">OpenEarthTools</a>.
% OpenEarthTools is an online collaboration to share and manage data and 
% programming tools in an open source, version controlled environment.
% Sign up to recieve regular updates of this function, and to contribute 
% your own tools.

%% Version <http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html>
% Created: 14 Mar 2012
% Created with Matlab version: 7.7.0.471 (R2008b)

% $Id$
% $Date$
% $Author$
% $Revision$
% $HeadURL$
% $Keywords: $

%%
id = [7e+006 7.00002e+006 7.00003e+006 7.00004e+006 7.00005e+006 7.00006e+006 7.00007e+006 7.00009e+006 7.00011e+006 7.00013e+006 7.00015e+006 7.00017e+006 7.00019e+006 7.00021e+006 7.00023e+006 7.00025e+006 7.00027e+006 7.00029e+006 7.00031e+006 7.00033e+006 7.00035e+006 7.00037e+006 7.00039e+006 7.00041e+006 7.00043e+006 7.00045e+006 7.00047e+006 7.00049e+006 7.00051e+006 7.00053e+006 7.00055e+006 7.00057e+006 7.00059e+006 7.00061e+006 7.00063e+006 7.00065e+006 7.00067e+006 7.00069e+006 7.00071e+006 7.00073e+006 7.00075e+006 7.00077e+006 7.00079e+006 7.00081e+006 7.00083e+006 7.00085e+006 7.00087e+006 7.00089e+006 7.00091e+006 7.00093e+006 7.00095e+006 7.00097e+006 7.00098e+006 7.00099e+006 7.001e+006 7.00102e+006 7.00102e+006 7.00103e+006 7.00105e+006 7.00105e+006 7.00106e+006 7.00108e+006 7.00109e+006 7.00109e+006 7.00111e+006 7.00112e+006 7.00112e+006 7.00114e+006 7.00115e+006 7.00115e+006 7.00117e+006 7.00118e+006 7.00118e+006 7.0012e+006 7.00121e+006 7.00121e+006 7.00123e+006 7.00124e+006 7.00124e+006 7.00126e+006 7.00127e+006 7.00127e+006 7.00129e+006 7.0013e+006 7.0013e+006 7.00132e+006 7.00134e+006 7.00136e+006 7.00138e+006 7.0014e+006 7.00142e+006 7.00144e+006 7.00146e+006 7.00148e+006 7.0015e+006 7.00152e+006 7.00154e+006 7.00157e+006 7.00159e+006 7.00161e+006 7.00163e+006 7.00165e+006 7.00167e+006 7.00169e+006 7.00171e+006 7.00173e+006 7.00175e+006 7.00176e+006 7.00176e+006 7.00178e+006 7.00178e+006 7.00179e+006 7.00181e+006 7.00183e+006 7.00184e+006 7.00186e+006 7.00188e+006 7.0019e+006 7.0019e+006 7.00191e+006 7.00193e+006 7.00193e+006 7.00194e+006 7.00196e+006 7.00196e+006 7.00197e+006 7.00198e+006 7.00199e+006 7.002e+006 7.00201e+006 7.00202e+006 7.00202e+006 7.00204e+006 7.00206e+006 7.00207e+006 7.00208e+006 7.0021e+006 7.00211e+006 7.00212e+006 7.00213e+006 7.00215e+006 7.00216e+006 7.00217e+006 7.00219e+006 7.0022e+006 7.00221e+006 7.00223e+006 7.00224e+006 7.00225e+006 7.00226e+006 7.00228e+006 7.0023e+006 7.00232e+006 7.00233e+006 7.00235e+006 7.00236e+006 7.00237e+006 7.00239e+006 7.0024e+006 7.00242e+006 7.00243e+006 7.00244e+006 7.00245e+006 7.00247e+006 7.00249e+006 7.0025e+006 7.00251e+006 7.00253e+006 7.00256e+006 7.00258e+006 7.0026e+006 7.00261e+006 7.00263e+006 7.00265e+006 7.00268e+006 7.0027e+006 7.00272e+006 7.00273e+006 7.00275e+006 7.00276e+006 7.00278e+006 7.0028e+006 7.00282e+006 7.00283e+006 7.00285e+006 7.00286e+006 7.00288e+006 7.0029e+006 7.00292e+006 7.00294e+006 7.00295e+006 7.00297e+006 7.00299e+006 7.003e+006 7.00303e+006 7.00305e+006 7.00308e+006 7.0031e+006 7.00313e+006 7.00315e+006 7.00318e+006 7.0032e+006 7.00323e+006 7.00325e+006 7.00328e+006 7.0033e+006 7.00333e+006 7.00335e+006 7.00338e+006 7.0034e+006 7.00343e+006 7.00345e+006 7.00348e+006 7.0035e+006 7.00353e+006 7.00355e+006 7.00358e+006 7.0036e+006 7.00363e+006 7.00365e+006 7.00368e+006 7.0037e+006 7.00373e+006 7.00375e+006 7.00378e+006 7.0038e+006 7.00383e+006 7.00385e+006 7.00388e+006 7.0039e+006 7.00393e+006 7.00395e+006 7.00398e+006 7.004e+006 7.00403e+006 7.00405e+006 7.00408e+006 7.0041e+006 7.00413e+006 7.00415e+006 7.00418e+006 7.0042e+006 7.00423e+006 7.00425e+006 7.00428e+006 7.0043e+006 7.00433e+006 7.00435e+006 7.00438e+006 7.0044e+006 7.00443e+006 7.00445e+006 7.00448e+006 7.0045e+006 7.00453e+006 7.00455e+006 7.00458e+006 7.0046e+006 7.00463e+006 7.00465e+006 7.00468e+006 7.0047e+006 7.00473e+006 7.00475e+006 7.00478e+006 7.0048e+006 7.00483e+006 7.00485e+006 7.00488e+006 7.0049e+006 7.00493e+006 7.00495e+006 7.00498e+006 7.005e+006 7.00503e+006 7.00505e+006 7.00508e+006 7.0051e+006 7.00513e+006 7.00515e+006 7.00518e+006 7.0052e+006 7.00523e+006 7.00525e+006 7.00528e+006 7.0053e+006 7.00533e+006 7.00535e+006 7.00538e+006 7.0054e+006 7.00543e+006 7.00545e+006 7.00548e+006 7.0055e+006];

OPT = struct(...
    'id', id,...[0 7001503],...
    'year', 2009,...
    'n_samples', 1000);

%%
OPT = setproperty(OPT, varargin);
% 
% %%
% refprof = ismember(OPT.id, 0);
% [xj zj xr zr] = deal([]);
% if any(~refprof)
%     tr = jarkus_transects(...
%         'id', OPT.id(~refprof),...
%         'year', OPT.year);
%     % interpolate nans in cross-shore direction (default)
%     tr = jarkus_interpolatenans(tr);
%     
%     [xj zj] = deal(tr.cross_shore, squeeze(tr.altitude));
% end
% 
% if any(refprof)
%     [xr zr] = SimpleProfile;
% end
% 
% x = unique([xj(:); xr(:)]);
% z = interp1(xj, zj, x);

stochast = struct(...
    'Name', {
        'profileix'...
        'D50'...
        'WL_t'...
        'Hsig_t'...
        'Tp_t'...
        },...
    'Distr', {
        @unif_inv...
        @norm_inv...
        @conditionalWeibull...
        @norm_inv...
        @norm_inv...
        },...
    'Params', {
        {0 1}...
        num2cell([1 .1]*225e-6)...
        {1.95 7.237 0.57 0.0158}...
        {{@getHsig_t 'WL_t' 4.35 .6 .0008 7 4.67} 0.6}...
        {{@interp1...
            [3.339 4.227 4.862 5.367 5.791 6.159 6.484 6.777 7.044 7.289 7.516 7.728 7.926 8.114 8.291 8.459 8.619 8.771 8.917 9.057 9.192 9.322 9.447 9.568 9.684 9.798]...
            [7.821 8.61 9.235 9.756 10.204 10.598 10.95 11.269 11.561 11.83 12.079 12.312 12.531 12.737 12.932 13.117 13.293 13.461 13.621 13.775 13.923 14.065 14.203 14.335 14.463 14.586]...
            'Hsig_t' 'linear' 'extrap'} 1}...
        },...
    'propertyName', {
        true...
        true...
        true...
        true...
        true...
        } ...
    );


% [x z] = SimpleProfile;

sampling = struct(                              ...
    'Name', {                                   ...
        'WL_t'                                  ...
    },                                          ...
    'Method', {                                 ...
        @prob_is_uniform                        ...
    },                                          ...
    'Params', {                                 ...
        num2cell(norm_inv(exp(-[1e-1 1e-8]),0,1))  ...
    }                                           ...
);

MCresult = MC(...
    'stochast', stochast,...
    'NrSamples', 10000,...
    'IS', sampling,...
    'x2zFunction', @debn_x2zfunction,...
    'x2zVariables', {'id' OPT.id 'year' OPT.year 'filename' fullfile(fileparts(which(mfilename)), '..', 'netica', 'testcase8.cas')});