예제 #1
0
        /// <summary>
        /// This will set all parameters in the ensembly with the same name than that of the parameter names
        /// of fit function at index <c>idx</c> to their default values (those are provided by the fit function).
        /// </summary>
        /// <param name="idx">Index of the fit element.</param>
        public void SetDefaultParametersForFitElement(int idx)
        {
            FitElement fitele = _fitEnsemble[idx];

            if (fitele.FitFunction == null)
            {
                return;
            }

            var byName = new System.Collections.Hashtable();

            for (int i = 0; i < _currentParameters.Count; i++)
            {
                byName.Add(_currentParameters[i].Name, i);
            }

            for (int i = 0; i < fitele.NumberOfParameters; ++i)
            {
                int k = (int)byName[fitele.ParameterName(i)];
                _currentParameters[k].Parameter = fitele.FitFunction.DefaultParameterValue(i);
            }

            _currentParameters.OnInitializationFinished();
        }
예제 #2
0
        public void CopyParametersBackTo(ParameterSet pset)
        {
            if (pset.Count != _constantParameters.Length)
            {
                throw new ArgumentException("Length of parameter set pset does not match with cached length of parameter set");
            }
            int varyingPara = 0;

            for (int i = 0; i < pset.Count; i++)
            {
                if (pset[i].Vary)
                {
                    varyingPara++;
                }
            }

            if (varyingPara != _cachedVaryingParameters.Length)
            {
                throw new ArgumentException("Number of varying parameters in pset does not match cached number of varying parameters");
            }

            varyingPara = 0;
            for (int i = 0; i < pset.Count; i++)
            {
                if (pset[i].Vary)
                {
                    pset[i].Parameter = _cachedVaryingParameters[varyingPara];
                    pset[i].Variance  = _resultingCovariances == null ? 0 : Math.Sqrt(_resultingCovariances[varyingPara + varyingPara * _cachedVaryingParameters.Length]);
                    varyingPara++;
                }
                else
                {
                    pset[i].Parameter = _constantParameters[i];
                    pset[i].Variance  = 0;
                }
            }
            pset.OnInitializationFinished();
        }
예제 #3
0
		public void CopyParametersBackTo(ParameterSet pset)
		{
			if (pset.Count != this._constantParameters.Length)
				throw new ArgumentException("Length of parameter set pset does not match with cached length of parameter set");
			int varyingPara = 0;
			for (int i = 0; i < pset.Count; i++)
			{
				if (pset[i].Vary)
					varyingPara++;
			}

			if (varyingPara != this._cachedVaryingParameters.Length)
				throw new ArgumentException("Number of varying parameters in pset does not match cached number of varying parameters");

			varyingPara = 0;
			for (int i = 0; i < pset.Count; i++)
			{
				if (pset[i].Vary)
				{
					pset[i].Parameter = this._cachedVaryingParameters[varyingPara];
					pset[i].Variance = _resultingCovariances == null ? 0 : Math.Sqrt(_resultingCovariances[varyingPara + varyingPara * _cachedVaryingParameters.Length]);
					varyingPara++;
				}
				else
				{
					pset[i].Parameter = this._constantParameters[i];
					pset[i].Variance = 0;
				}
			}
			pset.OnInitializationFinished();
		}