public ContinousOptUnit(string id, DoubleRange valueRange) : base(id) { Contract.Requires(!string.IsNullOrEmpty(id)); ValueRange = valueRange; }
/// <summary> /// Initializes a new instance of the <see cref="UniformGenerator"/> class. /// </summary> /// /// <param name="range">Random numbers range.</param> /// <param name="seed">Seed value to initialize random numbers generator.</param> /// public UniformGenerator(DoubleRange range, int seed) { rand = new UniformOneGenerator(seed); min = range.Min; length = range.Length; }
private void parseRanges() { if (ranges.Count == 0) { SourceMask = SourceMask.Replace("\n", ""); var strArray = SourceMask.Split(',').Select(x => x.Trim()).Where(y => !string.IsNullOrEmpty(y)); foreach (var currItem in strArray) { var strItem = currItem; if (!strItem.Contains("-")) strItem += "-" + strItem; var rangeArr = strItem.Split('-').Select(x => x.Trim()).ToArray(); if (rangeArr.Length == 2) { var strMin = rangeArr[0]; var strMax = rangeArr[1]; if (!strMax.Contains(".")) strMax = strMax + @".99"; var strPattern = @"[A-Z]\d{2}.*"; if (Regex.IsMatch(strMin, strPattern) && Regex.IsMatch(strMax, strPattern)) { var newRange = new DoubleRange(); newRange.MinValue = mkbToDouble(strMin); newRange.MaxValue = mkbToDouble(strMax); ranges.Add(newRange); } } } } }
/// <summary> /// Initializes a new instance of the <see cref="AxisScale"/> class with the given range. /// </summary> /// <param name="min">The min value.</param> /// <param name="max">The max value.</param> /// <exception cref="ArgumentException"> /// [<paramref name="min"/>, <paramref name="max"/>] is not a valid range. /// </exception> protected AxisScale(double min, double max) { if (!(min < max)) throw new ArgumentException("min must be less than max."); _range = new DoubleRange(min, max); }
public void ConstructorTest() { var range = new DoubleRange(-1.2, +3.4); Assert.AreEqual(-1.2, range.Min); Assert.AreEqual(+3.4, range.Max); }
public void MassRangeFromDANegative() { var range1 = new DoubleRange(10, new Tolerance(ToleranceUnit.DA, 4)); var range2 = new DoubleRange(10, new Tolerance(ToleranceUnit.DA, -4)); Assert.AreEqual(range1, range2); }
/// <summary> /// Initializes a new instance of the <see cref="AxisScale"/> class with the given range. /// </summary> /// <param name="range">The range of the axis.</param> /// <exception cref="ArgumentException"> /// <paramref name="range"/> is invalid. /// </exception> protected AxisScale(DoubleRange range) { if (!(range.Min < range.Max)) throw new ArgumentException("Invalid range.", "range"); _range = range; }
public BinaryFeatureDescription(string id, Type arrayType, int arrayLength, DoubleRange? itemValueRange = null, object context = null) : this(id, GetItemType(arrayType), arrayLength, itemValueRange, context) { Contract.Requires(!string.IsNullOrEmpty(id)); Contract.Requires(itemValueRange == null || !itemValueRange.Value.IsFixed); Contract.Requires(arrayLength > 0); Contract.Requires(arrayType != null); }
public RangedAdjustablePropertyValue(DoubleRange range, double value) { Contract.Requires(!range.IsFixed); Contract.Requires(range.IsIn(value)); Range = range; this.value = value; }
private static DoubleRange? EnsureItemValueRange(DoubleRange? itemValueRange, BinaryItemType itemType) { Contract.Ensures(Contract.Result<DoubleRange?>() != null); if (itemValueRange == null) { switch (itemType) { case BinaryItemType.Boolean: return new DoubleRange(0.0, 1.0); case BinaryItemType.Byte: return new DoubleRange(0.0, byte.MaxValue); case BinaryItemType.Int16: return new DoubleRange(short.MinValue, short.MaxValue); case BinaryItemType.Int32: return new DoubleRange(int.MinValue, int.MaxValue); case BinaryItemType.Int64: return new DoubleRange(long.MinValue, long.MaxValue); case BinaryItemType.UInt16: return new DoubleRange(ushort.MinValue, ushort.MaxValue); case BinaryItemType.UInt32: return new DoubleRange(uint.MinValue, uint.MaxValue); case BinaryItemType.UInt64: return new DoubleRange(ulong.MinValue, ulong.MaxValue); case BinaryItemType.Float: return new DoubleRange(float.MinValue, float.MaxValue); case BinaryItemType.Double: return new DoubleRange(double.MinValue, double.MaxValue); } } else { switch (itemType) { case BinaryItemType.Boolean: return Bordered(itemValueRange.Value, new DoubleRange(0.0, 1.0)); case BinaryItemType.Byte: return Bordered(itemValueRange.Value, new DoubleRange(0.0, byte.MaxValue)); case BinaryItemType.Int16: return Bordered(itemValueRange.Value, new DoubleRange(short.MinValue, short.MaxValue)); case BinaryItemType.Int32: return Bordered(itemValueRange.Value, new DoubleRange(int.MinValue, int.MaxValue)); case BinaryItemType.Int64: return Bordered(itemValueRange.Value, new DoubleRange(long.MinValue, long.MaxValue)); case BinaryItemType.UInt16: return Bordered(itemValueRange.Value, new DoubleRange(ushort.MinValue, ushort.MaxValue)); case BinaryItemType.UInt32: return Bordered(itemValueRange.Value, new DoubleRange(uint.MinValue, uint.MaxValue)); case BinaryItemType.UInt64: return Bordered(itemValueRange.Value, new DoubleRange(ulong.MinValue, ulong.MaxValue)); case BinaryItemType.Float: return Bordered(itemValueRange.Value, new DoubleRange(float.MinValue, float.MaxValue)); case BinaryItemType.Double: return Bordered(itemValueRange.Value, new DoubleRange(double.MinValue, double.MaxValue)); } } throw new ArgumentException(itemType + " is unknown.", "itemType"); }
protected FeatureDescription(string id, DoubleRange originalValueRange, object context = null) { Contract.Requires(!string.IsNullOrEmpty(id)); Contract.Requires(!originalValueRange.IsFixed); ID = id; Context = context; OriginalValueRange = originalValueRange; }
public BinaryFeatureDescription(string id, BinaryItemType itemType, int itemCount, DoubleRange? itemValueRange = null, object context = null) : base(id, EnsureItemValueRange(itemValueRange, itemType).Value, context) { Contract.Requires(!string.IsNullOrEmpty(id)); Contract.Requires(itemValueRange == null || !itemValueRange.Value.IsFixed); Contract.Requires(itemCount > 0); ItemType = itemType; ItemCount = itemCount; }
public ScoreDistribution(DoubleRange oneStar, DoubleRange twoStar, DoubleRange threeStar, DoubleRange fourStar, DoubleRange fiveStar) { _oneStar = oneStar; _twoStar = twoStar; _threeStar = threeStar; _fourStar = fourStar; _fiveStar = fiveStar; }
public static bool ValidatePriceRange(SearchCriteria criteria, DoubleRange priceRange) { // If the user specified a price range, but the item has no price information, fail if (criteria.PriceRange.HasRangeSpecified && !priceRange.HasRangeSpecified) { return false; } if (criteria.PriceRange != null && criteria.PriceRange.HasRangeSpecified) { if (priceRange == null) return false; if (!criteria.PriceRange.Overlaps(priceRange)) return false; } return true; }
public ScoreDistribution(double[] scores) { // Ensure that there are five categories being supplied. if (scores.Length != 5) { throw new ArgumentException("Score distribution must have five scores."); } _oneStar = new DoubleRange(scores[0],scores[0]); _twoStar = new DoubleRange(scores[1], scores[1]); _threeStar = new DoubleRange(scores[2], scores[2]); _fourStar = new DoubleRange(scores[3], scores[3]); _fiveStar = new DoubleRange(scores[4], scores[4]); }
public ValueRangeControl(string name, DoubleRange range) { this._range = range; // Set up grid with four coulmns, one row ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(20, GridUnitType.Star); this.ColumnDefinitions.Add(col); col = new ColumnDefinition(); col.Width = new GridLength(20, GridUnitType.Star); this.ColumnDefinitions.Add(col); col = new ColumnDefinition(); col.Width = new GridLength(20, GridUnitType.Star); this.ColumnDefinitions.Add(col); col = new ColumnDefinition(); col.Width = new GridLength(20, GridUnitType.Star); this.ColumnDefinitions.Add(col); RowDefinition row = new RowDefinition(); row.Height = new GridLength(100, GridUnitType.Star); // TODO: remove the set row if it's not necessary TextBlock from = new TextBlock(); from.Text = name + " from :"; this.Children.Add(from); Grid.SetColumn(from,0); Grid.SetRow(from,0); TextBoxPlus low = new TextBoxPlus(); low.Text = range.Low.ToString(); this.Children.Add(low); Grid.SetColumn(low, 1); Grid.SetRow(low,0); TextBlock to = new TextBlock(); to.Text = " to : "; this.Children.Add(to); Grid.SetColumn(to, 2); Grid.SetRow(to, 0); TextBoxPlus high = new TextBoxPlus(); if (range.High < double.MaxValue) { high.Text = range.High.ToString(); } Grid.SetColumn(high, 3); Grid.SetRow(high, 0); }
internal IEnumerable<double?> GetFeatureValues(Feature feature, DoubleRange normalizationRange) { Contract.Requires(feature != null); Contract.Requires(!normalizationRange.IsFixed); foreach (double? value in GetFeatureValues(feature)) { if (value.HasValue) { yield return OriginalValueRange.Normalize(value.Value, normalizationRange); } else { yield return null; } } }
public SearchCriteria(string searchText, double numberOfResults, DoubleRange priceRange, ScoreDistribution distribution, double minNumberReviews = 0, bool matchAllSearchTerms = false, bool strictPrimeEligibility = false ) { _searchText = searchText; _numberOfResults = numberOfResults; _matchAllSearchTerms = matchAllSearchTerms; _minNumberReviews = minNumberReviews; _strictPrimeEligibility = strictPrimeEligibility; _distribution = distribution; _priceRange = priceRange; }
public AmazonItem(string name, int reviewCount, DoubleRange priceRange, ScoreDistribution reviewDistribution, Uri url, double rating, bool primeEligible, BitmapImage image) { _name = name; _reviewCount = reviewCount; _priceRange = priceRange; _reviewDistribution = reviewDistribution; _url = url; _rating = rating; _primeEligible = primeEligible; _image = image; }
public static Chromatogram GetClosetsPeakChromatogram(this IEnumerable<ISpectrumTime> spectra, DoubleRange range) { if (range == null) { throw new ArgumentException("A range must be declared for a m/z range chromatogram"); } List<double> times = new List<double>(); List<double> intensities = new List<double>(); foreach (ISpectrumTime spectrum in spectra) { times.Add(spectrum.Time); var peak = spectrum.GetClosestPeak(range); intensities.Add((peak != null) ? peak.Intensity : 0); } return new MassRangeChromatogram(times.ToArray(), intensities.ToArray(), range); }
public static Chromatogram GetExtractedIonChromatogram(this IEnumerable<ISpectrumTime> spectra, DoubleRange range) { if (range == null) { throw new ArgumentException("A range must be declared for a m/z range chromatogram"); } List<double> times = new List<double>(); List<double> intensities = new List<double>(); foreach (ISpectrumTime spectrum in spectra) { double intensity; spectrum.TryGetIntensities(range, out intensity); times.Add(spectrum.Time); intensities.Add(intensity); } return new MassRangeChromatogram(times.ToArray(), intensities.ToArray(), range); }
public void EqualityTest() { // ReSharper disable SuspiciousTypeConversion.Global var range0 = new DoubleRange(-1.2, +3.4); var range1 = new DoubleRange(-1.2, +3.4); var range2 = new DoubleRange(0, +3.4); var range3 = new DoubleRange(-1.2, +3.5); var range4 = new DoubleRange(double.NaN, +3.4); var range5 = new DoubleRange(double.NaN, double.NaN); // Equals(DoubleRange) Assert.IsTrue(range0.Equals(range0)); Assert.IsTrue(range0.Equals(range1)); Assert.IsFalse(range0.Equals(range2)); Assert.IsFalse(range0.Equals(range3)); Assert.IsFalse(range0.Equals(range4)); Assert.IsTrue(range5.Equals(range5)); // Equals(object) Assert.IsTrue(range0.Equals((object)range0)); Assert.IsTrue(range0.Equals((object)range1)); Assert.IsFalse(range0.Equals((object)range2)); Assert.IsFalse(range0.Equals((object)range3)); Assert.IsFalse(range0.Equals((object)range4)); Assert.IsTrue(range5.Equals((object)range5)); Assert.IsFalse(range0.Equals(null)); Assert.IsFalse(range0.Equals(range0.ToString())); // == operator Assert.IsTrue(range0 == range1); Assert.IsFalse(range0 == range2); Assert.IsFalse(range0 == range3); Assert.IsFalse(range0 == range4); // != operator Assert.IsFalse(range0 != range1); Assert.IsTrue(range0 != range2); Assert.IsTrue(range0 != range3); Assert.IsTrue(range0 != range4); // ReSharper restore SuspiciousTypeConversion.Global }
protected internal override Feature CreateFeature(IEnumerator<double?> valueEnumerator, DoubleRange valueNormalizationRange) { byte[] bytes; MemoryStream ms; using (var writer = new BinaryWriter(ms = new MemoryStream())) { for (int idx = 0; idx < ItemCount; idx++) { double? value = GetNext(valueEnumerator); Write(writer, value, valueNormalizationRange); } bytes = ms.ToArray(); } return new BinaryFeature(this, bytes); }
private double DeterminePurity(MSDataScan scan, double mz, int charge, DoubleRange isolationRange) { var miniSpectrum = scan.GetReadOnlySpectrum().Extract(isolationRange); double expectedSpacing = Constants.C13C12Difference/charge; double min = expectedSpacing*0.95; double max = expectedSpacing*1.05; double totalIntensity = 0; double precursorIntensity = 0; foreach (MZPeak peak in miniSpectrum) { double difference = (peak.MZ - mz) * charge; double difference_Rounded = Math.Round(difference); double expected_difference = difference_Rounded * Constants.C13C12Difference; double Difference_ppm = (Math.Abs((expected_difference - difference) / (mz * charge))) * 1000000; if (Difference_ppm <= 25) { precursorIntensity += peak.Intensity; } totalIntensity += peak.Intensity; } return precursorIntensity / totalIntensity; }
private static DoubleRange Bordered(DoubleRange range, DoubleRange borderRange) { double min = range.MinValue, max = range.MaxValue; if (min < borderRange.MinValue) min = borderRange.MinValue; if (max > borderRange.MaxValue) max = borderRange.MaxValue; return new DoubleRange(min, max); }
/// <summary> /// Scales a variable from a scale into another, effectively /// performing a rule of three on scales bundaries. /// </summary> /// <param name="x">The variable to be scaled.</param> /// <param name="from">The original scale of the variable.</param> /// <param name="to">The destination scale of the variable.</param> /// <returns>The scaled variable.</returns> public static double Scale(double x, DoubleRange from, DoubleRange to) { return ((x - from.Min) * to.Length / from.Length) + to.Min; }
private void UpdateMarkers() { if (DataPointTemplate == null) { // This is a line chart without markers. return; } double markerThreshold = MarkerThreshold; if (!Numeric.IsNaN(markerThreshold)) { int numberOfDataPoints = _endIndexExclusive - _startIndex; int allowedNumberOfDataPoints = (int)(XAxis.Length * markerThreshold); if (numberOfDataPoints > allowedNumberOfDataPoints) { // The number of data points exceeds the MarkerThreshold. return; } } var yAxis = YAxis; var originY = yAxis.OriginY; var length = yAxis.Length; var yRange = new DoubleRange(originY - length, originY); // Loop over data points and create markers. for (int i = _startIndex; i < _endIndexExclusive; i++) { // Draw only data which is in the visible data range. if (!yRange.Contains(_yPositions[i])) continue; // Create marker DataPoint data = Data[i]; FrameworkElement marker = CreateDataPoint(data.DataContext ?? data); if (marker == null) return; Canvas.Children.Add(marker); // Save index in tag for PositionMarker(). // Alternatively, we could set the property as an attached property. marker.Tag = i; #if SILVERLIGHT // In Silverlight: Position marker immediately, because some elements do not raise a // SizeChanged event. PositionMarker(marker); #endif // Position the marker as soon as it is measured. marker.SizeChanged += MarkerSizeChanged; } }
/// <summary> /// Displays a scatter plot. /// </summary> /// /// <param name="title">The title for the plot window.</param> /// <param name="function">The function to plot.</param> /// <param name="range">The functions argument range to be plotted.</param> /// public static DataSeriesBox Show(String title, Func <double, double> function, DoubleRange range) { return(show(title, function, range.Min, range.Max, null, null)); }
/// <summary> /// Constructs a new <see cref="RombergMethod">Romberg's integration method</see>. /// </summary> /// /// <param name="steps">The number of steps used in Romberg's method. Default is 6.</param> /// public RombergMethod(int steps) { this.s = new double[steps]; Range = new DoubleRange(0, 1); }
public ProcVarOutOfRangeForm(INumericFormat iNumericFormat, ProcessVar var, object varSpecifiedValue, ErrorMessage error) { // // Required for Windows Form Designer support // InitializeComponent(); this.Text = error.Title; this.var = var; // display the message this.labelMessage.Text = error.Message; // dispaly the variable this.labelProcVarName.InitializeVariable(var); this.labelProcVarName.BorderStyle = BorderStyle.None; this.textBoxExistingValue.InitializeVariable(iNumericFormat, var); // note: the specified value is already converted to the current unit system, // it needs only to be formated if (var is ProcessVarDouble) { double val = (double)varSpecifiedValue; if (val == Constants.NO_VALUE) { this.textBoxSpecifiedValue.Text = ""; } else { this.textBoxSpecifiedValue.Text = val.ToString(iNumericFormat.NumericFormatString); } } else if (var is ProcessVarInt) { int val = (int)varSpecifiedValue; if (val == Constants.NO_VALUE_INT) { this.textBoxSpecifiedValue.Text = ""; } else { this.textBoxSpecifiedValue.Text = val.ToString(UI.DECIMAL); } } string averageValStr = ""; object minMaxValues = error.ProcessVarsAndValues.GetVarRange(var); // note: the min and max values are not converted to the current unit system, // and they also needs formating if (var is ProcessVarDouble) { DoubleRange doubleRange = (DoubleRange)minMaxValues; double valMin = doubleRange.MinValue; double val2Min = 0.0; val2Min = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, valMin); if (val2Min == Constants.NO_VALUE) { this.textBoxMinValue.Text = ""; } else { this.textBoxMinValue.Text = val2Min.ToString(iNumericFormat.NumericFormatString); } double valMax = doubleRange.MaxValue; double val2Max = 0.0; val2Max = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, valMax); if (val2Max == Constants.NO_VALUE) { this.textBoxMaxValue.Text = ""; } else { this.textBoxMaxValue.Text = val2Max.ToString(iNumericFormat.NumericFormatString); } double averageVal = (val2Min + val2Max) / 2; averageValStr = averageVal.ToString(iNumericFormat.NumericFormatString); } else if (var is ProcessVarInt) { IntRange intRange = (IntRange)minMaxValues; int valMin = intRange.MinValue; if (valMin == Constants.NO_VALUE_INT) { this.textBoxMinValue.Text = ""; } else { this.textBoxMinValue.Text = valMin.ToString(UI.DECIMAL); } int valMax = intRange.MaxValue; if (valMax == Constants.NO_VALUE_INT) { this.textBoxMaxValue.Text = ""; } else { this.textBoxMaxValue.Text = valMax.ToString(UI.DECIMAL); } int averageVal = (int)((valMin + valMax) / 2); averageValStr = averageVal.ToString(iNumericFormat.NumericFormatString); } // as convenience, initialize the new value with the recommended value this.textBoxNewValue.Text = averageValStr; this.textBoxExistingValue.BackColor = Color.Gainsboro; this.textBoxSpecifiedValue.BackColor = Color.Gainsboro; this.textBoxMinValue.BackColor = Color.Gainsboro; this.textBoxMaxValue.BackColor = Color.Gainsboro; }
/// <summary> /// Paints the control. /// </summary> /// protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; int clientWidth = ClientRectangle.Width; int clientHeight = ClientRectangle.Height; // fill with background g.FillRectangle(backgroundBrush, 0, 0, clientWidth - 1, clientHeight - 1); // draw borders g.DrawRectangle(bordersPen, 0, 0, clientWidth - 1, clientHeight - 1); if (DesignMode) { return; } DoubleRange rangeClientX = new DoubleRange(0, clientWidth); DoubleRange rangeClientY = new DoubleRange(clientHeight, 0); // walk through all data series foreach (Waveform waveform in waveTable.Values) { // get data of the waveform float[] data = waveform.data; // check for available data if (data == null) { continue; } using (Pen pen = new Pen(waveform.color, waveform.width)) { if (SimpleMode) { int blockSize = waveform.samples / clientWidth; for (int x = 0; x < clientWidth; x++) { double max = data.RootMeanSquare(x * blockSize, blockSize); int y = clientHeight / 2 + (int)(max * clientHeight); g.DrawLine(pen, x, clientHeight - y, x, y); } } else { int xPrev = 0; int yPrev = (int)rangeY.Scale(rangeClientY, data[0]); for (int x = 0; x < clientWidth; x++) { int index = (int)rangeClientX.Scale(rangeX, x); if (index < 0 || index >= data.Length) { index = data.Length - 1; } int y = (int)rangeY.Scale(rangeClientY, data[index]); g.DrawLine(pen, xPrev, yPrev, x, y); xPrev = x; yPrev = y; } } } } }
public DoubleValueRange(DoubleRange inRange) { _range = inRange; }
/// <summary> /// Initializes a new instance of the <see cref="GaussianFunction"/> class. /// </summary> /// public GaussianFunction(double alpha, DoubleRange range) { this.Alpha = alpha; this.Range = range; }
/// <summary> /// Estimates appropriate values for sigma given a data set. /// </summary> /// /// <remarks> /// This method uses a simple heuristic to obtain appropriate values /// for sigma in a radial basis function kernel. The heuristic is shown /// by Caputo, Sim, Furesjo and Smola, "Appearance-based object /// recognition using SVMs: which kernel should I use?", 2002. /// </remarks> /// /// <param name="kernel">The inner kernel.</param> /// <param name="inputs">The data set.</param> /// <param name="samples">The number of random samples to analyze.</param> /// <param name="range">The range of suitable values for sigma.</param> /// /// <returns>A Gaussian kernel initialized with an appropriate sigma value.</returns> /// public static Gaussian <T> Estimate <T>(T kernel, double[][] inputs, int samples, out DoubleRange range) where T : IDistance, IKernel, ICloneable { if (samples > inputs.Length) { throw new ArgumentOutOfRangeException("samples"); } double[] distances = Distances <T>(kernel, inputs, samples); double q1 = Math.Sqrt(distances[(int)Math.Ceiling(0.15 * distances.Length)] / 2.0); double q9 = Math.Sqrt(distances[(int)Math.Ceiling(0.85 * distances.Length)] / 2.0); double qm = Math.Sqrt(BestCS.Statistics.Tools.Median(distances, alreadySorted: true) / 2.0); range = new DoubleRange(q1, q9); return(new Gaussian <T>(kernel, sigma: qm)); }
/// <summary> /// Estimate appropriate values for sigma given a data set. /// </summary> /// /// <remarks> /// This method uses a simple heuristic to obtain appropriate values /// for sigma in a radial basis function kernel. The heuristic is shown /// by Caputo, Sim, Furesjo and Smola, "Appearance-based object /// recognition using SVMs: which kernel should I use?", 2002. /// </remarks> /// /// <param name="kernel">The inner kernel.</param> /// <param name="inputs">The data set.</param> /// <param name="range">The range of suitable values for sigma.</param> /// /// <returns>A Gaussian kernel initialized with an appropriate sigma value.</returns> /// public static Gaussian <T> Estimate <T>(T kernel, double[][] inputs, out DoubleRange range) where T : IDistance, IKernel, ICloneable { return(Estimate(kernel, inputs, inputs.Length, out range)); }
/// <summary> /// Estimate appropriate values for sigma given a data set. /// </summary> /// /// <remarks> /// This method uses a simple heuristic to obtain appropriate values /// for sigma in a radial basis function kernel. The heuristic is shown /// by Caputo, Sim, Furesjo and Smola, "Appearance-based object /// recognition using SVMs: which kernel should I use?", 2002. /// </remarks> /// /// <param name="inputs">The data set.</param> /// <param name="range">The range of suitable values for sigma.</param> /// /// <returns>A Gaussian kernel initialized with an appropriate sigma value.</returns> /// public static Gaussian Estimate(double[][] inputs, out DoubleRange range) { return(Estimate(inputs, inputs.Length, out range)); }
private static void ReportInverseSolverROfRho(double drho, double[] rhoRange, InverseFitType IFT, string projectName, string inputPath, ForwardSolverType[] forwardSolverTypes, OptimizerType[] optimizerTypes, IEnumerable <OpticalProperties> guessOps, IEnumerable <OpticalProperties> realOps, int ratioDetectors, double noisePercentage, bool stepByStep) { Console.WriteLine("#############################################"); Console.WriteLine("####### REPORT INVERSE SOLVER: ROfRho #######"); Console.WriteLine("#############################################"); //path definition string spaceDomainFolder = "Real"; string timeDomainFolder = "SteadyState"; string problemFolder = "drho" + drho.ToString() + "/" + "ratioD" + ratioDetectors.ToString() + "/" + "noise" + noisePercentage.ToString() + "/" + rhoRange[0].ToString() + "_" + rhoRange[1].ToString(); problemFolder = problemFolder.Replace(".", "p"); //rhos based on range int numberOfPoints = Convert.ToInt32((rhoRange[1] - rhoRange[0]) / drho) + 1; var rhos = new DoubleRange(rhoRange[0], rhoRange[1], numberOfPoints).AsEnumerable().ToArray(); double[] R = new double[numberOfPoints]; double[] S = new double[numberOfPoints]; //based on range evaluate the index of first and last points to use int firstInd = Convert.ToInt32((rhoRange[0] + drho / 2.0) / drho) - 1; int lastInd = Convert.ToInt32((rhoRange[1] + drho / 2) / drho) - 1; //execute foreach (var fST in forwardSolverTypes) { Console.WriteLine("Forward Solver Type: {0}", fST.ToString()); foreach (var oT in optimizerTypes) { Console.WriteLine("Optimizer Type: {0}", oT.ToString()); if (stepByStep) { Console.WriteLine("Press enter to continue"); } Console.WriteLine("================================================="); if (stepByStep) { Console.ReadLine(); } foreach (var rOp in realOps) { //output double bestMua = 0.0; double meanMua = 0.0; double guessBestMua = 0.0; double bestMusp = 0.0; double meanMusp = 0.0; double guessBestMusp = 0.0; double bestChiSquared = 10000000000000.0; //initialize very large to avoid if first double meanChiSquared = 0.0; DateTime start = new DateTime(); //processing start time DateTime end = new DateTime(); //processing finish time double elapsedSeconds; //processing time //set filename based on real optical properties var filename = "musp" + rOp.Musp.ToString() + "mua" + rOp.Mua.ToString(); filename = filename.Replace(".", "p"); Console.WriteLine("Looking for file {0}", filename); if (File.Exists(inputPath + spaceDomainFolder + "/" + timeDomainFolder + "/" + filename + "R")) { Console.WriteLine("The file has been found"); //read binary files var Rtot = (IEnumerable <double>)FileIO.ReadArrayFromBinaryInResources <double> ("Resources/" + spaceDomainFolder + "/" + timeDomainFolder + "/" + filename + "R", projectName, 88); var Stot = (IEnumerable <double>)FileIO.ReadArrayFromBinaryInResources <double> ("Resources/" + spaceDomainFolder + "/" + timeDomainFolder + "/" + filename + "S", projectName, 88); // extract points within range for (int i = firstInd; i <= lastInd; i++) { R[i - firstInd] = Rtot.ToArray()[i]; S[i - firstInd] = Stot.ToArray()[i]; } // reduce number of measurements var mrhos = FilterArray(rhos, ratioDetectors); var mR = FilterArray(R, ratioDetectors); var mS = FilterArray(S, ratioDetectors); // add noise if (noisePercentage != 0.0) { mR.AddNoise(noisePercentage); } start = DateTime.Now; int covergedCounter = 0; foreach (var gOp in guessOps) { bool converged; //if fitting only one parameter change the guess to the true value if (IFT == InverseFitType.Mua) { gOp.Musp = rOp.Musp; } if (IFT == InverseFitType.Musp) { gOp.Mua = rOp.Mua; } //solve inverse problem double[] fit = ComputationFactory.SolveInverse(fST, oT, SolutionDomainType.ROfRho, mR, mS, IFT, new object[] { new[] { gOp }, mrhos }); if (fit[0] != 0 && fit[1] != 0) { converged = true; } else { converged = false; } // fitted op if (converged) { OpticalProperties fOp = new OpticalProperties(fit[0], fit[1], gOp.G, gOp.N); //calculate chi squared and change values if it improved double chiSquared = EvaluateChiSquared(mR, SolverFactory.GetForwardSolver(fST).ROfRho(fOp.AsEnumerable(), mrhos).ToArray(), mS); if (chiSquared < bestChiSquared) { guessBestMua = gOp.Mua; bestMua = fit[0]; guessBestMusp = gOp.Musp; bestMusp = fit[1]; bestChiSquared = chiSquared; } meanMua += fit[0]; meanMusp += fit[1]; meanChiSquared += chiSquared; covergedCounter += 1; } } end = DateTime.Now; meanMua /= covergedCounter; meanMusp /= covergedCounter; meanChiSquared /= covergedCounter; elapsedSeconds = (end - start).TotalSeconds; MakeDirectoryIfNonExistent(new string[] { spaceDomainFolder, timeDomainFolder, problemFolder, fST.ToString(), oT.ToString(), IFT.ToString() }); //write results to array double[] inverseProblemValues = FillInverseSolverValuesArray(bestMua, meanMua, guessBestMua, bestMusp, meanMusp, guessBestMusp, bestChiSquared, meanChiSquared, elapsedSeconds, mR.Count()); // write array to binary LocalWriteArrayToBinary(inverseProblemValues, @"Output/" + spaceDomainFolder + "/" + timeDomainFolder + "/" + problemFolder + "/" + fST.ToString() + "/" + oT.ToString() + "/" + IFT.ToString() + "/" + filename, FileMode.Create); Console.WriteLine("Real MUA = {0} - best MUA = {1} - mean MUA = {2}", rOp.Mua, bestMua, meanMua); Console.WriteLine("Real MUSp = {0} - best MUSp = {1} - mean MUSp = {2}", rOp.Musp, bestMusp, meanMusp); if (stepByStep) { Console.ReadLine(); } } else { Console.WriteLine("The file has not been found."); } Console.Clear(); } } } }
/// <summary> /// Initializes a new instance of the <see cref="LinearFunction"/> class. /// </summary> /// public LinearFunction(DoubleRange range) { this.Range = range; }
/// <summary> /// Initializes a new instance of the <see cref="UniformGenerator"/> class. /// </summary> /// /// <param name="range">Random numbers range.</param> /// /// <remarks>Initializes random numbers generator with zero seed.</remarks> /// public UniformGenerator(DoubleRange range) : this(range, 0) { }
/// <summary> /// Computes the circular quartiles of the given circular angles. /// </summary> /// /// <param name="angles">A double array containing the angles in radians.</param> /// <param name="range">The sample quartiles, as an out parameter.</param> /// <param name="wrap"> /// Whether range values should be wrapped to be contained in the circle. If /// set to false, range values could be returned outside the [+pi;-pi] range. /// </param> /// /// <returns>The median of the given angles.</returns> /// public static double Quartiles(double[] angles, out DoubleRange range, bool wrap = true) { return(Quartiles(angles, out range, Median(angles), wrap)); }
/// <summary> /// Creates an interval vector. /// </summary> /// public static double[] Interval(this DoubleRange range, double stepSize) { return(Interval(range.Min, range.Max, stepSize)); }
/// <summary> /// Creates a new column options. /// </summary> /// public Options(String name) : base(name) { this.SourceRange = new DoubleRange(0, 1); this.OutputRange = new DoubleRange(-1, 1); }
public List <PSM> crunch(List <PSM> psms) { var rawFile = new ThermoRawFile(rawpath); rawFile.Open(); List <int> msOneScanNumbers = new List <int>(); foreach (var scan in rawFile) { if (scan.MsnOrder == 1) { msOneScanNumbers.Add(scan.SpectrumNumber); } } //ReadInTargets(peptidesPath, rawFile); foreach (PSM psm in psms) { LFPeptide pep = psmToLFPeptide(psm, rawFile); targetPeptides.Add(pep); } // Question: how do we sync the list of PSMs with the intensity of the LFPeptide // They will be in same order List <LFPeptide> pepsWithSmooth = new List <LFPeptide>(); if (rawFile.GetMzAnalyzer(msOneScanNumbers[0]).Equals(MZAnalyzerType.Orbitrap)) { var firstSpectrumRT = rawFile.GetRetentionTime(rawFile.FirstSpectrumNumber); var lastSpectrumRT = rawFile.GetRetentionTime(rawFile.LastSpectrumNumber); foreach (var pep in targetPeptides) { var startTime = Math.Max(pep.parentMS1Time - 2, firstSpectrumRT); var stopTime = Math.Min(pep.parentMS1Time + 2, lastSpectrumRT); pep.startLookupTime = startTime; pep.stopLookupTime = stopTime; pep.FirstScan = rawFile.GetSpectrumNumber(pep.startLookupTime); pep.LastScan = rawFile.GetSpectrumNumber(pep.stopLookupTime); pep.lookupRange = DoubleRange.FromPPM(pep.UserMZ, 10); } foreach (var ms1 in msOneScanNumbers) { var spectrum = rawFile.GetSpectrum(ms1); GetXICs(spectrum, ms1, rawFile.GetRetentionTime(ms1)); rawFile.ClearCachedScans(); List <LFPeptide> peptidesForExtract = targetPeptides.Where(x => x.doneBuildingXIC && !x.extractedXIC).ToList(); foreach (var pep in peptidesForExtract) { try { pep.SmoothLibrary = Smoothing.GetRollingAveragePeaks(pep, 11, true); if (pep.SmoothLibrary.Count != 0) { ExtractFeatures.GetApexPeak(pep, true); ExtractFeatures.GetFWHMWindow(pep); LFPeptide pepSmooth = (LFPeptide)pep.Clone(); pepsWithSmooth.Add(pepSmooth); pep.XICLibrary.Clear(); } }catch (Exception e) {/** * System.Windows.Forms.MessageBox.Show("XICLibraryCount: " + pep.XICLibrary.Count + "Peptide: " + pep.sequence + "\n" + e.ToString()); **/ } } } List <LFPeptide> peptidesToWrite = targetPeptides.Where(x => x.doneBuildingXIC && !x.extractedXIC).ToList(); //Changed from psms.Count to pepswithsmooth.Count //for(int i = 0; i < psms.Count; i++) for (int i = 0; i < pepsWithSmooth.Count; i++) { /** * if(psms[i].scanTime == 20.45) * { * double[] xs = new double[pepsWithSmooth[i].SmoothLibrary.Count]; * double[] ys = new double[pepsWithSmooth[i].SmoothLibrary.Count]; * * StreamWriter writer = new StreamWriter(@"C:\Users\gwilson\Desktop\GlycoQuant - Injs\TLN[NGlycan_1216.42286271]CSGAHVK_0.5_2_PolynomialFit.csv"); * for (int k = 0; k < pepsWithSmooth[i].SmoothLibrary.Count; k++) * { * xs[k] = pepsWithSmooth[i].SmoothLibrary[k].RT; * ys[k] = pepsWithSmooth[i].SmoothLibrary[k].Intensity; * * //writer.WriteLine(pepsWithSmooth[i].SmoothLibrary[k].RT + "," + pepsWithSmooth[i].SmoothLibrary[k].Intensity); * * * if (pepsWithSmooth[i].SmoothLibrary[k].RT > targetPeptides[i].LeftFWHM.RT && pepsWithSmooth[i].SmoothLibrary[k].RT < targetPeptides[i].RightFWHM.RT) * { * writer.WriteLine(pepsWithSmooth[i].SmoothLibrary[k].RT + "," + pepsWithSmooth[i].SmoothLibrary[k].Intensity); * } * * } * * double[] p = Fit.Polynomial(xs, ys, 3) * * for(int j = 0; j < p.Length; j++) * { * //writer.WriteLine() * } * * writer.Close(); * } **/ double intensity = 0; try { for (int j = 0; j < pepsWithSmooth[i].SmoothLibrary.Count - 1; j++) { // Intensity is the sum of peak intensities from Left FWHM to Right FWHM /** * if (pepsWithSmooth[i].SmoothLibrary[j].RT > targetPeptides[i].LeftFWHM.RT && pepsWithSmooth[i].SmoothLibrary[j].RT < targetPeptides[i].RightFWHM.RT) * { * intensity += pepsWithSmooth[i].SmoothLibrary[j].Intensity; * } **/ // Retention times double RT1 = pepsWithSmooth[i].SmoothLibrary[j].RT; double RT2 = pepsWithSmooth[i].SmoothLibrary[j + 1].RT; // Intensities double int1 = pepsWithSmooth[i].SmoothLibrary[j].Intensity; double int2 = pepsWithSmooth[i].SmoothLibrary[j + 1].Intensity; //Rectangle area double rectArea = (RT2 - RT1) * Math.Min(int1, int2); //Triangle Area double triArea = ((RT2 - RT1) * Math.Abs(int1 - int2)) / 2; intensity += rectArea + triArea; } } catch (Exception e) { Console.ReadKey(); } psms[i].intensity = intensity; //psms[i].intensity = targetPeptides[i].apexPeakLibrary.Intensity; } rawFile.Dispose(); return(psms); } rawFile.Dispose(); return(psms); }
/// <summary> /// Displays a scatter plot. /// </summary> /// /// <param name="function">The function to plot.</param> /// <param name="range">The functions argument range to be plotted.</param> /// <param name="step">The step size to use during plotting.</param> /// public static ScatterplotBox Show(Func <double, double> function, DoubleRange range, double step) { return(show(null, function, range.Min, range.Max, step)); }
/// <summary> /// InitializeVectorsAndInterpolators reads in reference database and initializes data /// Note that the reference data is now in mm/ns so no conversion needed /// </summary> private void InitializeVectorsAndInterpolators() { // load R(rho,time) reference data var rOfRhoAndTime = (dynamic)DetectorIO.ReadDetectorFromFileInResources("ROfRhoAndTime", "Modeling/Resources/" + folder, _assemblyName); nrReference = rOfRhoAndTime.Rho.Count - 1; drReference = rOfRhoAndTime.Rho.Delta; ntReference = rOfRhoAndTime.Time.Count - 1; dtReference = rOfRhoAndTime.Time.Delta; // assume mus' used by Kienle muspReference = 1.0; RhoReference = new DoubleRange(drReference / 2, drReference * nrReference - drReference / 2, nrReference).AsEnumerable().ToArray(); TimeReference = new DoubleRange(dtReference / 2, dtReference * ntReference - dtReference / 2, ntReference).AsEnumerable().ToArray(); RReferenceOfRhoAndTime = new double[nrReference, ntReference]; for (int ir = 0; ir < nrReference; ir++) { double sum = 0.0; for (int it = 0; it < ntReference; it++) { RReferenceOfRhoAndTime[ir, it] = rOfRhoAndTime.Mean[ir, it]; sum += rOfRhoAndTime.Mean[ir, it]; // debug line } } // load R(fx,time) reference data var rOfFxAndTime = (dynamic)DetectorIO.ReadDetectorFromFileInResources("ROfFxAndTime", "Modeling/Resources/" + folder, _assemblyName); nfxReference = rOfFxAndTime.Fx.Count; dfxReference = 1.0 / nfxReference; FxReference = new DoubleRange(dfxReference / 2, dfxReference * nfxReference - dfxReference / 2, nfxReference).AsEnumerable().ToArray(); RReferenceOfFxAndTime = new double[nfxReference, ntReference]; for (int ifx = 0; ifx < nfxReference; ifx++) { for (int it = 0; it < ntReference; it++) // this only goes to 800 not 801 because ntReference determined from ROfRhoAndTime.txt { RReferenceOfFxAndTime[ifx, it] = rOfFxAndTime.Mean[ifx, it].Real; } } ////if (File.Exists("Resources/" + folder + @"R_fxt")) //if (true) //{ // RReferenceOfFxAndTime = (double[,])FileIO.ReadArrayFromBinaryInResources<double>("Modeling/Resources/" + // folder + @"R_fxt", _assemblyName); //} //else //{ // double[] RReferenceOfRhoAndTj = new double[nrReference]; // double[] RReferenceOfFxAndTj = new double[nfxReference]; // for (int j = 0; j < ntReference; j++) // { // for (int k = 0; k < nrReference; k++) // { // RReferenceOfRhoAndTj[k] = RReferenceOfRhoAndTime[k, j]; // get ROfRho at a particular Time Tj // } // for (int i = 0; i < nfxReference; i++) // { // RReferenceOfFxAndTime[i, j] = LinearDiscreteHankelTransform.GetHankelTransform(RhoReference, // RReferenceOfRhoAndTj, drReference, dfxReference * i); // } // } // FileIO.WriteArrayToBinary<double>(RReferenceOfFxAndTime, @"/R_fxt"); //} }
/// <summary> /// Displays a scatter plot. /// </summary> /// /// <param name="title">The title for the plot window.</param> /// <param name="function">The function to plot.</param> /// <param name="range">The functions argument range to be plotted.</param> /// public static ScatterplotBox Show(String title, Func <double, double> function, DoubleRange range) { return(show(title, function, range.Min, range.Max, null)); }
/// <summary> /// Scales variables from a scale into another, effectively /// performing a rule of three on scales bundaries. /// </summary> /// <param name="x">The variables to be scaled.</param> /// <param name="from">The original scale of the variables.</param> /// <param name="to">The destination scale of the variables.</param> /// <returns>The scaled variables.</returns> public double[] Scale(double[] x, DoubleRange from, DoubleRange to) { double[] r = new double[x.Length]; for (int i = 0; i < x.Length; i++) { r[i] = Scale(x[i], from, to); } return r; }
public PointValueRange(DoubleRange inX, DoubleRange inY, DoubleRange inZ) { _rangeX = inX; _rangeY = inY; _rangeZ = inZ; }
/// <summary> /// Constructs a new <see cref="TrapezoidalRule"/> integration method. /// </summary> /// /// <param name="steps">The number of steps into which the integration /// interval will be divided.</param> /// public TrapezoidalRule(int steps) { Steps = steps; Range = new DoubleRange(0, 1); }
/// <summary>Update event.</summary> protected override void OnSizeChanged() { this.Confidence = GetConfidenceInterval(1.0 - Size); }
public static double Clamp(this double value, DoubleRange valueRange) { return(Clamp(value, valueRange.Minimum, valueRange.Maximum)); }
//---------------------------------------------------------------------- public void SetValues(DoubleRange range) { SetValues(range.Min, range.Extent); }
private static void ReportInverseSolverROfRhoAndTime(double dt, double riseMarker, double tailMarker, string stDevMode, InverseFitType IFT, string projectName, string inputPath, ForwardSolverType[] forwardSolverTypes, OptimizerType[] optimizerTypes, IEnumerable <OpticalProperties> guessOps, IEnumerable <OpticalProperties> realOps, double[] rhos, double noisePercentage, bool stepByStep) { Console.WriteLine("#############################################"); Console.WriteLine("##### REPORT INVERSE SOLVER: ROfRhoAndT #####"); Console.WriteLine("#############################################"); //path definition string spaceDomainFolder = "Real"; string timeDomainFolder = "TimeDomain"; string noiseFolder = "noise" + noisePercentage.ToString(); string problemFolder = "dt" + (dt * 1000).ToString() + "markers" + riseMarker.ToString() + tailMarker.ToString(); problemFolder = problemFolder.Replace(".", "p"); foreach (var fST in forwardSolverTypes) { //initialize forward solver Console.WriteLine("Forward Solver Type: {0}", fST.ToString()); foreach (var oT in optimizerTypes) { Console.WriteLine("Optimizer Type: {0}", oT.ToString()); foreach (var rho in rhos) { string rhoFolder = rho.ToString(); Console.WriteLine("================================================="); Console.WriteLine("SOURCE DETECTOR SEPARETION: R = {0} mm", rhoFolder); if (stepByStep) { Console.WriteLine("Press enter to continue"); } Console.WriteLine("================================================="); if (stepByStep) { Console.ReadLine(); } rhoFolder = rhoFolder.Replace(".", "p"); rhoFolder = "rho" + rhoFolder; double[] constantVals = { rho }; foreach (var rOp in realOps) { //output double bestMua = 0.0; double meanMua = 0.0; double guessBestMua = 0.0; double bestMusp = 0.0; double meanMusp = 0.0; double guessBestMusp = 0.0; double bestChiSquared = 10000000000000.0; //initialize very large to avoid if first double meanChiSquared = 0.0; DateTime start = new DateTime(); //processing start time DateTime end = new DateTime(); //processing finish time double elapsedSeconds; //processing time //set filename based on real optical properties var filename = "musp" + rOp.Musp.ToString() + "mua" + rOp.Mua.ToString(); filename = filename.Replace(".", "p"); Console.WriteLine("Looking for file {0}", filename); if (File.Exists(inputPath + spaceDomainFolder + "/" + timeDomainFolder + "/" + problemFolder + "/" + rhoFolder + "/" + filename + "Range")) { Console.WriteLine("The file has been found for rho = {0} mm.", rho); //read binary files var timeRange = (double[])FileIO.ReadArrayFromBinaryInResources <double> ("Resources/" + spaceDomainFolder + "/" + timeDomainFolder + "/" + problemFolder + "/" + rhoFolder + "/" + filename + "Range", projectName, 2); // CKH 4/20/20 quickfix to avoid exception, somehow binary read of timeRange have timeRange[1]=0 if ((timeRange[1] - timeRange[0] < 0) || (Math.Abs(timeRange[1] - timeRange[0]) > 2e9)) { break; } int numberOfPoints = Convert.ToInt32((timeRange[1] - timeRange[0]) / dt) + 1; var T = new DoubleRange(timeRange[0], timeRange[1], numberOfPoints).AsEnumerable().ToArray(); var R = (double[])FileIO.ReadArrayFromBinaryInResources <double> ("Resources/" + spaceDomainFolder + "/" + timeDomainFolder + "/" + problemFolder + "/" + rhoFolder + "/" + filename + "R", projectName, numberOfPoints); var S = GetStandardDeviationValues("Resources/" + spaceDomainFolder + "/" + timeDomainFolder + "/" + problemFolder + "/" + rhoFolder + "/" + filename + "S", projectName, stDevMode, numberOfPoints, R.ToArray()); // add noise if (noisePercentage != 0.0) { R = R.AddNoise(noisePercentage); } start = DateTime.Now; int convergedCounter = 0; foreach (var gOp in guessOps) { bool converged; if (IFT == InverseFitType.Mua) { gOp.Musp = rOp.Musp; } if (IFT == InverseFitType.Musp) { gOp.Mua = rOp.Mua; } //solve inverse problem double[] fit = ComputationFactory.SolveInverse(fST, oT, SolutionDomainType.ROfRhoAndTime, R, S, IFT, new object[] { new[] { gOp }, constantVals, T }); if (fit[0] != 0 && fit[1] != 0) { converged = true; } else { converged = false; } if (converged) { OpticalProperties fOp = new OpticalProperties(fit[0], fit[1], gOp.G, gOp.N); //calculate chi squared and change best values if it improved double chiSquared = EvaluateChiSquared(R.ToArray(), SolverFactory.GetForwardSolver(fST).ROfRhoAndTime(fOp.AsEnumerable(), rho.AsEnumerable(), T).ToArray(), S.ToArray()); if (chiSquared < bestChiSquared) { guessBestMua = gOp.Mua; bestMua = fit[0]; guessBestMusp = gOp.Musp; bestMusp = fit[1]; bestChiSquared = chiSquared; } meanMua += fit[0]; meanMusp += fit[1]; meanChiSquared += chiSquared; convergedCounter += 1; } } end = DateTime.Now; meanMua /= convergedCounter; meanMusp /= convergedCounter; meanChiSquared /= convergedCounter; elapsedSeconds = (end - start).TotalSeconds; MakeDirectoryIfNonExistent(new string[] { spaceDomainFolder, timeDomainFolder, noiseFolder, problemFolder, fST.ToString(), oT.ToString(), IFT.ToString(), rhoFolder }); //write results to array double[] inverseProblemValues = FillInverseSolverValuesArray(bestMua, meanMua, guessBestMua, bestMusp, meanMusp, guessBestMusp, bestChiSquared, meanChiSquared, elapsedSeconds, numberOfPoints); // write array to binary LocalWriteArrayToBinary(inverseProblemValues, @"Output/" + spaceDomainFolder + "/" + timeDomainFolder + "/" + noiseFolder + "/" + problemFolder + "/" + fST.ToString() + "/" + oT.ToString() + "/" + IFT.ToString() + "/" + rhoFolder + "/" + filename, FileMode.Create); Console.WriteLine("Real MUA = {0} - best MUA = {1} - mean MUA = {2}", rOp.Mua, bestMua, meanMua); Console.WriteLine("Real MUSp = {0} - best MUSp = {1} - mean MUSp = {2}", rOp.Musp, bestMusp, meanMusp); if (stepByStep) { Console.ReadLine(); } } else { Console.WriteLine("The file has not been found."); } Console.Clear(); } } } } }
public static double Scale(this DoubleRange from, DoubleRange to, double x) { return(Accord.Math.Vector.Scale(x, from, to)); }
private void Write(BinaryWriter writer, double? value, DoubleRange valueNormalizationRange) { if (value == null) { WriteDefault(writer); } else { double currentValue = OriginalValueRange.Denormalize(valueNormalizationRange.Cut(value.Value), valueNormalizationRange); switch (ItemType) { case BinaryItemType.Boolean: writer.Write(currentValue >= 0.5); return; case BinaryItemType.Byte: writer.Write((byte)Math.Round(currentValue)); return; case BinaryItemType.Int16: writer.Write((short)Math.Round(currentValue)); return; case BinaryItemType.Int32: writer.Write((int)Math.Round(currentValue)); return; case BinaryItemType.Int64: writer.Write((long)Math.Round(currentValue)); return; case BinaryItemType.UInt16: writer.Write((ushort)Math.Round(currentValue)); return; case BinaryItemType.UInt32: writer.Write((uint)Math.Round(currentValue)); return; case BinaryItemType.UInt64: writer.Write((ulong)Math.Round(currentValue)); return; case BinaryItemType.Float: writer.Write((float)currentValue); return; case BinaryItemType.Double: writer.Write(currentValue); return; } } }
public static double[] Scale(DoubleRange from, DoubleRange to, double[] x) { return(Accord.Math.Vector.Scale(values: x, fromRange: from, toRange: to)); }
public static double Scale(IntRange from, DoubleRange to, int x) { return(Accord.Math.Vector.Scale(x, from, to)); }
/// <summary> /// Creates an interval vector. /// </summary> /// public static double[] Interval(this DoubleRange range, int steps) { return(Interval(range.Min, range.Max, steps)); }
/// <summary> /// Creates a new <see cref="NonAdaptiveGaussKronrod"/> integration algorithm. /// </summary> /// public NonAdaptiveGaussKronrod() { ToleranceAbsolute = 0; ToleranceRelative = 1e-3; range = new DoubleRange(0, 1); }
/// <summary> /// Initializes a new instance of the <see cref="LinearFunction"/> class. /// </summary> /// public LinearFunction(double alpha, DoubleRange range) { this.Alpha = alpha; this.Range = range; }