Wednesday, November 15, 2017

We continue our discussion on modeling. A model articulates how a system behaves quantitatively. Models use numerical methods to examine complex situations and come up with predictions. Most common techniques involved for coming up with a model include statistical techniques, numerical methods, matrix factorization and optimizations.  
A forward model is a mathematical model that is detailed enough to include the desired level of real world behaviour or features. It is used for simulating realistic experimental data which under the right constraints can be used to test hypothesis.  While it may be too complicated to fit experimental data, it can be used to generate synthetic data sets for evaluating parameters.
An inverse model is a mathematical model that fits experimental data. It aims to provide a best fit to the data. Values for the parameters are obtained from estimation techniques. It generally involves an iterative process to minimize the average difference. The quality of the inverse model is evaluated using well known mathematical techniques as well as intuition. 
A forward-inverse modeling is a process to combine data simulation with model fitting so that all parameters can be sufficiently evaluated for robustness, uniqueness and sensitivity. This is very powerful for improving data analysis and understanding the limitations.
A good inverse model should have a good fit and describe the data adequately so that some insights may follow.  The parameters are unique and their values are consistent with the hypothesis and changes to experimental data in response to alterations in the system. 
The steps for inverse modeling of data include:
1) selecting an appropriate mathematical model using say polynomial or other functions
2) defining an objective function that agrees between the data and the model
3) adjusting model parameters to get a best fit usually by minimizing the objective function
4) evaluating goodness of fit to data by not being perfect due to measurement noise
5) estimating accuracy of best fit parameter values
6) determining whether a much better fit is possible which might be necessary if there is local minima as compared to global minimum.
#codingexercise
Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.
List<int> GetMaxInSubArrayOfSizeK(List<int> A, int k)
{
    var ret = new List<int>();
    var q = new Deque<int>();
    for (int i = 0; i < k; i++)
    {
        while ( (q.IsEmpty() == false) && A[i] >= A[q.Last()])
            q.PopLast();

        q.AddLast(i);
    }

    for (int i = k ; i < A.Count; i++)
    {
        ret.Add(A[q.PeekFirst()]);

        while ( (q.IsEmpty() == false) && q.PeekFirst() <= i - k)
            q.PopFirst();

        while ( (q.IsEmpty() == false) && A[i] >= A[q.PeekLast()])
            q.PopLast();

        q.AddLast(i);
    }

    if (q.IsEmpty () == false)
         ret.Add(A [q.PeekFirst()]);
    return ret;
}


No comments:

Post a Comment