/// <summary> /// Initializes a new instance of the <see cref="RenderTarget" /> class. /// </summary> /// <param name="buffers">The render target buffers.</param> /// <param name="colorSpace">The render target color space.</param> /// <param name="sampling">The render target buffer sampling options.</param> public RenderTarget(TargetBuffers buffers = TargetBuffers.Color0, ColorSpace colorSpace = ColorSpace.Linear, Sampling sampling = Sampling.None) { if (buffers == TargetBuffers.None) { throw new ArgumentException("Render target must have at least one buffer.", nameof(buffers)); } if ((buffers & TargetBuffers.Color0) == TargetBuffers.Color0) { this.Color0 = new Texture2D(null, colorSpace, sampling); } if ((buffers & TargetBuffers.Color1) == TargetBuffers.Color1) { this.Color1 = new Texture2D(null, colorSpace, sampling); } if ((buffers & TargetBuffers.Color2) == TargetBuffers.Color2) { this.Color2 = new Texture2D(null, colorSpace, sampling); } if ((buffers & TargetBuffers.Color3) == TargetBuffers.Color3) { this.Color3 = new Texture2D(null, colorSpace, sampling); } if ((buffers & TargetBuffers.DepthStencil) == TargetBuffers.DepthStencil) { this.DepthStencil = new Texture2D(null, ColorSpace.sRGB, sampling & ~Sampling.Mipmap); } }
public SamplingFormVM(StudyUnitVM studyUnit) : base(studyUnit) { samplings = new ObservableCollection <SamplingVM>(); //change how to name the title //*Find the unique title like unsed //*The title such as Concept and Amount can be changed manually, //Cannot do here HashSet <string> titles = Sampling.CollectTitles(studyUnit.SamplingModels); foreach (Sampling samplingModel in studyUnit.SamplingModels) { int uniqIndex = EDOUtils.UniqOrderNo(titles, samplingModel.Title, PREFIX); SamplingVM sampling = new SamplingVM(samplingModel) { Parent = this, OrderNo = uniqIndex, OrderPrefix = PREFIX }; sampling.Init(); samplings.Add(sampling); titles.Add(sampling.Title); //Add in title set. } modelSyncher = new ModelSyncher <SamplingVM, Sampling>(this, samplings, studyUnit.SamplingModels); }
public void SampleMaxRateAlwaysReturnTrue() { for (int i = 0; i < 1000; i += 1) { Assert.True(Sampling.Sample(1.0)); } }
public override void Execute(State state, FastPriorityQueue <Event> eventQueue) { // Clear switch (no lane cleared if coming from depot) SwitchLane lane = fromDepot ? SwitchLane.None : Switch.ArrivalLaneFor(platform); eventQueue.Enqueue(new ClearSwitchLane(station, lane), state.time + Config.c.switchClearanceTime); // Log System.Diagnostics.Debug.WriteLine($"ArrivalEndstation: tram {tram.id}, station: {station.name}, {platform}, {lane}, time: {state.time}"); // Check if tram can do another round trip if it is at endstation with depot if (!station.TramToDepot(state.time)) { // Board and unboard (int pOut, int pIn, List <int> e) = station.UnboardAndBoard(tram, tram.passengerCount); entrances = e; // Calculate when to schedule departure // If boarding/unboarding takes shorter than the turnaround, take the turnaround time int passengerTransferTime = state.time + Math.Max(Sampling.passengerExchangeTime(pOut, pIn), Config.c.turnAroundTimeFor(station)); int nextDepartureTime = station.NextDeparture(); int nextEventTime = Math.Max(passengerTransferTime, nextDepartureTime); // Queue event eventQueue.Enqueue(new ExpectedDepartureStartstation(tram, station, platform, nextDepartureTime), nextEventTime); } // Transfer tram to depot else { station.Free(platform); } }
/// <summary> /// Main method begins the sampling program /// </summary> /// <param name="args">command line args as string[] array.</param> static void Main(string[] args) { Instant startOfSampling = new Instant(); Sampling sampling = new Sampling(); startOfSampling.Time = DateTime.Parse("2017-01-03T10:00:00"); List <Measurement> unsampleMeasurementsList = sampling.CreateSamples(); Map <MeasurementType, List <Measurement> > map = sampling.Sample(startOfSampling, unsampleMeasurementsList); // Writes unsampled input top display. Console.WriteLine("INPUT:"); for (int i = 0; i < unsampleMeasurementsList.Count; i++) { Console.WriteLine(unsampleMeasurementsList[i]); } // Outputs sampled measurments to display. Console.WriteLine("OUTPUT:"); foreach (KeyValuePair <MeasurementType, List <Measurement> > keyValuePair in map) { foreach (Measurement sampledMeasurement in keyValuePair.Value) { Console.WriteLine(sampledMeasurement); } } // To pause I used ReadKey. Console.ReadKey(); }
public void Setup() { // just in case a generator uses // randomization, need to have a // good starting seed Sampling.SetSeedFromSystemTime(); }
/// <summary> /// Merges a population with the current one. /// </summary> /// <param name="population">Population to merge with.</param> /// <param name="newPoolSize">Size of the pool to create, including the current pool and merging pool (defaults to current pool size).</param> /// <param name="balance">Balance rate of the first population pool (percentage). A higher rate will increase the selection rate of chromosomes in the first pool.</param> /// <param name="elites">Rate of elitist chromosomes in the resulting population from the previous pools (percentage).</param> /// <returns>Population.</returns> public virtual Population Merge(Population population, int newPoolSize, double balance = 0.5, double elites = 0.1) { if (balance > 1) { balance /= 100; } if (elites > 1) { elites /= 100; } int poolSize = (newPoolSize > 0 ? newPoolSize : this._Chromosomes.Count); int eliteCount = (int)System.Math.Ceiling(poolSize * elites); var population1 = this._Chromosomes; var population2 = population; var result = new List <IChromosome>(poolSize); result.AddRange(population1.Take(eliteCount)); result.AddRange(population2.Take(eliteCount)); poolSize = poolSize - eliteCount; for (int i = result.Count; i < poolSize; i++) { double rand = Sampling.GetUniform(); var item = (rand < balance ? population1.Random() : population2.Random()); result.Add(item); } return(new Population(result, this.FitnessMetric, this.FitnessMode)); }
/// <inheritdoc /> public override double GenerateRay(CameraSample sample, out Ray ray) { //ProfilePhase prof(Prof::GenerateCameraRay); // Compute raster and camera sample positions Point3D pFilm = new Point3D(sample.FilmPoint.X, sample.FilmPoint.Y, 0.0); Point3D pCamera = RasterToCamera.AtPoint(pFilm); ray = new Ray(new Point3D(0.0, 0.0, 0.0), pCamera.ToVector3D().Normalize()); // Modify ray for depth of field if (LensRadius > 0.0) { // Sample point on lens Point2D pLens = LensRadius * Sampling.ConcentricSampleDisk(sample.LensPoint); // Compute point on plane of focus double ft = FocalDistance / ray.Direction.Z; Point3D pFocus = ray.AtPoint(ft); // Update ray for effect of lens ray.Origin = new Point3D(pLens.X, pLens.Y, 0.0); ray.Direction = (pFocus - ray.Origin).ToVector3D().Normalize(); } ray.Time = PbrtMath.Lerp(sample.Time, ShutterOpen, ShutterClose); ray.Medium = Medium; ray = CameraToWorld.ExecuteTransform(ray); return(1.0); }
/// <inheritdoc /> public override Spectrum Sample_Wi( Interaction it, Point2D u, out Vector3D wi, out double pdf, out Point2D pRaster, out VisibilityTester vis) { // Uniformly sample a lens interaction _lensIntr_ Point2D pLens = LensRadius * Sampling.ConcentricSampleDisk(u); Point3D pLensWorld = CameraToWorld.ExecuteTransform(it.Time, new Point3D(pLens.X, pLens.Y, 0.0)); Interaction lensIntr = new Interaction(pLensWorld, it.Time, new MediumInterface(Medium)); lensIntr.N = (CameraToWorld.ExecuteTransform(it.Time, new Point3D(0.0, 0.0, 1.0))).ToVector3D().ToNormal3D(); // Populate arguments and compute the importance value vis = new VisibilityTester(it, lensIntr); wi = (lensIntr.P - it.P).ToVector3D(); double dist = wi.Length(); wi /= dist; // Compute PDF for importance arriving at _ref_ // Compute lens area of perspective camera double lensArea = LensRadius != 0.0 ? (Math.PI * LensRadius * LensRadius) : 1.0; pdf = (dist * dist) / (lensIntr.N.AbsDot(wi) * lensArea); return(We(lensIntr.SpawnRay(-wi), out pRaster)); }
public IHttpActionResult UploadRecording([FromBody] Sampling Sampling, HttpPostedFileBase file) { string Message = ""; string fileName = ""; // string extension = Path.GetExtension(file.FileName); try { if (ModelState.IsValid) { Sampling.AudioFileName = file.FileName; _context.Samplings.Add(Sampling); _context.SaveChanges(); Message = "1"; return(Ok(Message)); } if (file != null && file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/Uploads/Audio"), fileName); file.SaveAs(path); } Message = "1"; return(Ok(Message)); } catch (Exception ex) { Message = "0"; return(Ok(ex.Message)); } }
public SamplingVM(Sampling sampling) { this.sampling = sampling; this.universes = new ObservableCollection <UniverseVM>(); foreach (Universe universeModel in sampling.Universes) { UniverseVM universe = new UniverseVM(universeModel); universe.Parent = this; universes.Add(universe); } this.samplingNumbers = new ObservableCollection <SamplingNumberVM>(); foreach (SamplingNumber samplingNumberModel in sampling.SamplingNumbers) { SamplingNumberVM samplingNumber = new SamplingNumberVM(samplingNumberModel); samplingNumber.Parent = this; samplingNumbers.Add(samplingNumber); } samplingMethods = Options.SamplingMethods; collectorTypes = Options.CollectorTypes; if (string.IsNullOrEmpty(CollectorTypeCode)) { CollectorTypeCode = Sampling.DefaultCollectorType; } modelSyncher = new ModelSyncher <UniverseVM, Universe>(this, universes, sampling.Universes); modelSyncher2 = new ModelSyncher <SamplingNumberVM, SamplingNumber>(this, samplingNumbers, sampling.SamplingNumbers); }
public SignalPlot(PlotControls controls, VideoConstants constants, Sampling sampling) { Viewport = new Viewport(constants.VisibleWidth * controls.Location.Left, constants.VisibleHeight * controls.Location.Top, constants.VisibleWidth * controls.Location.Right, constants.VisibleHeight * controls.Location.Bottom); LayerSignal = new LayerSignal(Viewport, sampling, controls, controls.Location.Angle); LayerAxis = new LayerAxis(Viewport, controls.NumberOfDivisions, controls.Location.Angle); Controls = controls; }
/// <summary>Initializes the random.</summary> /// <param name="X">The Matrix to process.</param> /// <param name="k">The int to process.</param> /// <returns>A Matrix.</returns> private Matrix InitializeRandom(Matrix X, int k) { // initialize mean variables // to random existing points var m = Matrix.Zeros(k, X.Cols); var seeds = new List <int>(k); for (var i = 0; i < k; i++) { int index; do { // pick random row that has not yet // been used (need to fix this...) index = Sampling.GetUniform(k + 1); if (!seeds.Contains(index)) { seeds.Add(index); break; } }while (true); for (var j = 0; j < X.Cols; j++) { m[i, j] = X[index, j]; } } return(m); }
public override void Execute(State state, FastPriorityQueue <Event> eventQueue) { System.Diagnostics.Debug.WriteLine($"ExpectedDepartureStartstation: tram {tram.id}, station: {station.name}, {platform}, Timetable: {timeTableTime}, time: {state.time}"); // Close doors if it is time to leave if (state.time >= timeTableTime) { // Mark tram as ready for departure tram.ReadyForDeparture(); // Start leaving directly when possible SwitchLane lane = Switch.ExitLaneFor(platform); bool isFirst = station.first == platform; if (isFirst && station._switch.SwitchLaneFree(lane)) { station._switch.UseSwitchLane(lane); eventQueue.Enqueue(new DepartureStartstation(tram, station, platform), state.time); } } // Otherwise let extra passengers enter else { (int pInExtra, List <int> e) = station.BoardPassengers(tram); entrances = e; int extraTime = Sampling.passengerExchangeTime(0, pInExtra); eventQueue.Enqueue(new ExpectedDepartureStartstation(tram, station, platform, timeTableTime), state.time + extraTime); } }
public override void Execute(State state, FastPriorityQueue <Event> eventQueue) { var station = state.stations[stationIndex]; station.Free(); // Enqueue current tram if (station.HasQueue()) { Tram newOccupant = station.OccupyFromQueue(); eventQueue.Enqueue(new TramArrival(newOccupant, stationIndex), state.time + Config.c.stationClearanceTime); } // Schedule arrival at next station int newStationIndex = stationIndex + 1 == state.stations.Count ? 0 : stationIndex + 1; int drivingTime = Sampling.drivingTime(Config.c.transferTimes[stationIndex].averageTime); Debug.WriteLine($"TramDeparture: tram {tram.id}: {station.name}, dir: {station.direction}, time: {state.time}"); // Make sure trams do not take over each other int arrivalTime = station.SignalNextArrival(state.time + drivingTime); if (state.stations[newStationIndex] is Endstation endstation) { eventQueue.Enqueue(new ExpectedArrivalEndstation(tram, endstation), arrivalTime); } else { eventQueue.Enqueue(new ExpectedTramArrival(tram, newStationIndex), arrivalTime); } }
public DateTime Draw(DateTime from, DateTime to) { var span = to.Subtract(from); if (span.TotalDays < 360) { throw new InvalidOperationException("Can only work within year ranges for now..."); } var month = _months.Sample(); var dow = _dayOfWeek.Sample(); var hour = _hours.Sample(); var day = DateTime.DaysInMonth(from.Year, month); var year = new DateTime(from.Year, month, System.Math.Min(from.Day, day)) < from ? from.Year + 1 : from.Year; var date = Enumerable.Range(1, DateTime.DaysInMonth(year, month)) .Select(n => new DateTime(year, month, n)) .Where(d => d.DayOfWeek == dow) .GetRandom() .AddHours(hour) .AddMinutes(Sampling.GetUniform(59)) .AddSeconds(Sampling.GetUniform(59)); return(date); }
public static List <UInt16> ComputeRadicalInversePermutations(Random rng) { List <UInt16> perms; // Allocate space in _perms_ for radical inverse permutations int permArraySize = 0; for (int i = 0; i < PrimeTableSize; ++i) { permArraySize += Primes[i]; } perms = new List <UInt16>(permArraySize); int offset = 0; for (int i = 0; i < PrimeTableSize; ++i) { // Generate random permutation for $i$th prime base for (int j = 0; j < Primes[i]; ++j) { perms[offset + j] = Convert.ToUInt16(j); } Sampling.Shuffle(perms, offset, Primes[i], 1, rng); offset += Primes[i]; } return(perms); }
/// <summary> /// Performs crossover using point selection. /// </summary> /// <param name="chromosome1">First parent.</param> /// <param name="chromosome2">Second parent.</param> /// <returns></returns> public IChromosome Crossover(IChromosome chromosome1, IChromosome chromosome2) { this.InitPoints(chromosome1.Sequence.Length, this.IsDynamic); IChromosome parent = chromosome1; IChromosome clone = parent.Clone(); int split = 0; for (int i = 0; i < chromosome1.Sequence.Length; i++) { if (i == this.Points[split]) { // striated genes double p = Sampling.GetUniform(); if (p <= this.Probability) { parent = (parent == chromosome1 ? chromosome2 : chromosome1); } if (split < this.Points.Length - 1) { split++; } } // do crossover clone.Sequence[i] = parent.Sequence[i]; } return(clone); }
public override void Execute(State state, FastPriorityQueue <Event> eventQueue) { // Free the platform station.Free(platform); // Reset ready for departure tram.ResetReadyForDeparture(); // Claim lane SwitchLane lane = Switch.ExitLaneFor(platform); System.Diagnostics.Debug.WriteLine($"DepartureStartstation: tram {tram.id}, station: {station.name}, {platform}, {lane}, time: {state.time}"); // Clear the lane it's leaving over in 60s eventQueue.Enqueue(new ClearSwitchLane(station, lane), state.time + Config.c.switchClearanceTime); // Queue next arrival int stationIndex = state.stations.IndexOf(station); int newStationIndex = stationIndex + 1; // Make sure trams do not take over each other int drivingTime = Sampling.drivingTime(Config.c.transferTimes[stationIndex].averageTime); int arrivalTime = station.SignalNextArrival(state.time + drivingTime); eventQueue.Enqueue(new ExpectedTramArrival(tram, newStationIndex), arrivalTime); }
public object Create() { var span = _to - _from; var hrs = Sampling.GetUniform((int)System.Math.Floor(span.TotalHours - 1)); return(_from.AddHours(hrs)); }
private static StudyUnit DoLoadStudyUnit(string pathName) { StudyUnit studyUnit = Load <StudyUnit>(pathName); if (studyUnit == null) { return(null); } foreach (Member member in studyUnit.Members) { member.ConvertRoleCodeToRoleName(); } // old data files available(in which Data Collection is not yet tabbed) if (studyUnit.Sampling != null && studyUnit.Samplings.Count == 0) { Sampling sampling = studyUnit.Sampling; sampling.Universes.AddRange(studyUnit.Universes); studyUnit.Samplings.Add(studyUnit.Sampling); } foreach (Sampling sampling in studyUnit.Samplings) { sampling.ConvertMethodCodeToMethodName(); } studyUnit.Sampling = null; studyUnit.Universes.Clear(); studyUnit.CreateBinaryCodeScheme(); return(studyUnit); }
public ActionResult Edit([Bind(Include = "Id,BarCode,Iteration,Location,Comment,SamplingType_Id,SamplingStatus_Id,Appointment_Id")] Sampling sampling, SamplingType samplingType, string returnUrl) { if (ModelState.IsValid) { AddNewEntityIfNecessary(sampling, samplingType); db.Entry(sampling).State = EntityState.Modified; db.SaveChanges(User.Identity.Name); if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index")); } if (Session["Language"].ToString().ToLower() == "en") { ViewBag.SamplingStatus_Id = new SelectList(db.SamplingStatus, "Id", "Name", sampling.SamplingStatus_Id); ViewBag.SamplingType_Id = new SelectList(db.SamplingTypes, "Id", "Name", sampling.SamplingType_Id); } else { ViewBag.SamplingStatus_Id = new SelectList(db.SamplingStatus, "Id", "NameFr", sampling.SamplingStatus_Id); ViewBag.SamplingType_Id = new SelectList(db.SamplingTypes, "Id", "NameFr", sampling.SamplingType_Id); } return(View(sampling)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CentreId,Date,Salinity,Temp,O2")] Sampling sampling) { if (sampling == null || id != sampling.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sampling); await _context.SaveChangesAsync().ConfigureAwait(false); } catch (DbUpdateConcurrencyException) { if (!SamplingExists(sampling.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["CentreId"] = new SelectList(_context.Centre, "Id", "Id", sampling.CentreId); return(View(sampling)); }
public static List <string> CollectIds(StudyUnit studyUnit) { List <string> ids = new List <string>(); //0. StudyUnit itself CollectIds(studyUnit, ids); //1. Event CollectIds(studyUnit.Events, ids); //2. Member CollectIds(studyUnit.Members, ids); //3. Organization CollectIds(studyUnit.Organizations, ids); //4. Abstract CollectIds(studyUnit.Abstract, ids); //5. Coverage CollectIds(studyUnit.Coverage, ids); //6. Funding Agency CollectIds(studyUnit.FundingInfos, ids); //6-1. Organization including CollectIds(FundingInfo.GetOrganizations(studyUnit.FundingInfos), ids); //7.Universe CollectIds(Sampling.GetUniverses(studyUnit.Samplings), ids); //8.Sampling CollectIds(studyUnit.Samplings, ids); //9. Concept Scheme CollectIds(studyUnit.ConceptSchemes, ids); //9-1. Concept CollectIds(ConceptScheme.GetConcepts(studyUnit.ConceptSchemes), ids); //10. Question CollectIds(studyUnit.Questions, ids); //10-1. Answer CollectIds(Question.GetResponses(studyUnit.Questions), ids); //11. Category Scheme CollectIds(studyUnit.CategorySchemes, ids); //11-1. Category CollectIds(CategoryScheme.GetCategories(studyUnit.CategorySchemes), ids); //12. Code Scheme CollectIds(studyUnit.CodeSchemes, ids); //12-1. Code CollectIds(CodeScheme.GetCodes(studyUnit.CodeSchemes), ids); //13. Variable Scheme CollectIds(studyUnit.VariableScheme, ids); //14. Variable CollectIds(studyUnit.Variables, ids); //14-1. Answer CollectIds(Variable.GetResponses(studyUnit.Variables), ids); //15. Dataset CollectIds(studyUnit.DataSets, ids); //16. Data File CollectIds(studyUnit.DataFiles, ids); //17. Order of Question CollectIds(studyUnit.ControlConstructSchemes, ids); //17-1.Sequence CollectIds(ControlConstructScheme.GetSequences(studyUnit.ControlConstructSchemes), ids); //17-2.Constructs CollectIds(ControlConstructScheme.GetConstructs(studyUnit.ControlConstructSchemes), ids); return(ids); }
public void Test_Range_Single_Testing() { for (int i = 0; i < 10000; i++) { var t = Sampling.GetUniform(); Assert.IsTrue(Range.Make(t).Test(t)); } }
/// <summary> /// Set the temperature oversampling. /// </summary> /// <param name="sampling">The <see cref="Sampling"/> to set.</param> public void SetTemperatureSampling(Sampling sampling) { byte status = Read8BitsFromRegister(_controlRegister); status = (byte)(status & 0b0001_1111); status = (byte)(status | (byte)sampling << 5); _i2cDevice.Write(new[] { _controlRegister, status }); }
/// <summary> /// Mutates the chromosome using random replacement. /// </summary> /// <param name="chromosome">Chromosome to mutate.</param> /// <returns>IChromosome.</returns> public override IChromosome Mutate(IChromosome chromosome) { var clone = chromosome.Clone(); clone.Sequence[this.N] = Sampling.GetUniform(this.Range.Min, this.Range.Max); return(clone); }
/// <summary> /// Sets the temperature sampling to the given value /// </summary> /// <param name="sampling"></param> public void SetTemperatureSampling(Sampling sampling) { byte status = Read8BitsFromRegister((byte)Register.CTRL_MEAS); status = (byte)(status & 0b0001_1111); status = (byte)(status | (byte)sampling << 5); _i2cDevice.Write(new[] { (byte)Register.CTRL_MEAS, status }); }
/// <summary> /// Sets the pressure sampling to the given value /// </summary> /// <param name="sampling"></param> public void SetPressureSampling(Sampling sampling) { byte status = Read8BitsFromRegister((byte)Register.CTRL_MEAS); status = (byte)(status & 0b1110_0011); status = (byte)(status | (byte)sampling << 2); _i2cDevice.Write(new[] { (byte)Register.CTRL_MEAS, status }); }
/// <summary> /// Sets the pressure sampling. /// </summary> /// <param name="sampling">The <see cref="Sampling"/> to set.</param> public void SetPressureSampling(Sampling sampling) { byte status = Read8BitsFromRegister(_controlRegister); status = (byte)(status & 0b1110_0011); status = (byte)(status | (byte)sampling << 2); _i2cDevice.Write(new[] { _controlRegister, status }); }
public int Draw(int setcount) { if (setcount == 0) { throw new IndexOutOfRangeException("Cannot draw from an empty set"); } return(Sampling.GetUniform(1, setcount) - 1); }
/// <summary> /// Initializes a new instance of the <see cref="Texture2D" /> class. /// </summary> /// <param name="path">The source file path.</param> /// <param name="colorSpace">The source image color space.</param> /// <param name="sampling">The sampling options.</param> public Texture2D(string path, ColorSpace colorSpace, Sampling sampling = Sampling.None) : base(GL.TEXTURE_2D, colorSpace, sampling) { this.Image = new TextureImage(this, GL.TEXTURE_2D); if (path != null) { this.Ready = this.Load(path); } else { this.Ready = Task.CompletedTask; } }
TableKolmogorova table = new TableKolmogorova(); //таблица критерия #endregion Fields #region Methods public KolmogorovContainer Calculate(Sampling sampling, int type) { //создаём эземпляр практической функции распределения PracticalDistributionFunction function1 = new PracticalDistributionFunction(sampling); double d = D(function1, type); double λ = d * Math.Sqrt(sampling.GetVolume());//вычисляем λ double P = table.GetP(λ);//ищем по таблице результат KolmogorovContainer result = new KolmogorovContainer(); result.P = P; result.λ = λ; result.D = d; result.MeanSquareDeviation = function1.MeanSquareDeviation(sampling.AvеrageValue()); return result; }
/// <summary> /// Initializes a new instance of the <see cref="TextureCube" /> class. /// </summary> /// <param name="path">The asset file path.</param> /// <param name="colorSpace">The source image color space.</param> /// <param name="sampling">The sampling options.</param> public TextureCube(string path, ColorSpace colorSpace, Sampling sampling = Sampling.None) : base(GL.TEXTURE_CUBE_MAP, colorSpace, sampling) { this.PositiveX = new TextureImage(this, GL.TEXTURE_CUBE_MAP_POSITIVE_X); this.PositiveY = new TextureImage(this, GL.TEXTURE_CUBE_MAP_POSITIVE_Y); this.PositiveZ = new TextureImage(this, GL.TEXTURE_CUBE_MAP_POSITIVE_Z); this.NegativeX = new TextureImage(this, GL.TEXTURE_CUBE_MAP_NEGATIVE_X); this.NegativeY = new TextureImage(this, GL.TEXTURE_CUBE_MAP_NEGATIVE_Y); this.NegativeZ = new TextureImage(this, GL.TEXTURE_CUBE_MAP_NEGATIVE_Z); if (path != null) { this.Ready = this.Load(path); } else { this.Ready = Task.CompletedTask; } }
//конструктор public PracticalDistributionFunction(Sampling sampling) { Sampling Ranged = sampling.RangedSampling(); //упорядоченная выборка double P = (double)1 / Ranged.GetVolume();//частота одной точки Values.Add(new Point(Ranged.GetValue(0), P)); //добавляем первую точку к функции Ranged.DeletValue(Ranged.GetValue(0)); //удаляем её из выборки while (Ranged.GetVolume() != 0) //пока в выборке есть точки { double TemproraryProbability = Values[Values.Count - 1].GetP + P; if (Values[Values.Count - 1].GetX == Ranged.GetValue(0)) //если точка имеет то же значение что и последняя в функции { Values[Values.Count - 1] = new Point(Ranged.GetValue(0), TemproraryProbability); //увеличиваем значение функции в данной точке } else { Values.Add(new Point(Ranged.GetValue(0), TemproraryProbability)); //иначе добавляем к функции новую точку } Ranged.DeletValue(Ranged.GetValue(0)); //удаляем текущую точку из выборки } }
public static int SampleCount(Sampling bSampling) { return bSampling.Count > 1 ? bSampling.Count : 0; }
/// <summary> /// Creates a new <see cref="SwapChainDescription"/> structure. /// </summary> /// <param name="colorBufferCount">Number of the swap chain's color buffers.</param> /// <param name="colorBufferFormatID">Format of the swap chain's color buffer.</param> /// <param name="enableAutoDepthStencil">Specifies whether the swap chain should use its own (auto) depth-stencil buffer.</param> /// <param name="depthStencilFormatID">Format of the swap chain's auto depth-stencil buffer. If <see cref="EnableAutoDepthStencil"/> is set to false, this field is ignored.</param> /// <param name="sampling">A <see cref="Sampling"/> structure describing multi-sampling parameters.</param> /// <param name="verticalSync">Specifies whether the swap chain should wait for a monitor vertical refresh to present a new frame. /// <remarks>Using this option will remove the "tearing" effect and reduce the chance of the GPU overheat, /// but may reduce FPS if its non-synchronized value is below monitor's refresh rate. /// </remarks> /// </param> public SwapChainDescription( int colorBufferCount, int colorBufferFormatID, bool enableAutoDepthStencil, int depthStencilFormatID, Sampling sampling, bool verticalSync) { ColorBufferCount = colorBufferCount; ColorBufferFormatID = colorBufferFormatID; EnableAutoDepthStencil = enableAutoDepthStencil; DepthStencilFormatID = depthStencilFormatID; Sampling = sampling; VerticalSync = verticalSync; }
private int Volume; //объём выборки #endregion Fields #region Constructors //конструктор public PirsonCriterion(Sampling sampling,int intervals) { Intervals = intervals; ranged = sampling.RangedSampling();//упорядоченная выборка }
public Texture2DDescription( int width, int height, int mipLevels, int arraySize, int formatID, Sampling sampling, Usage usage, BindFlags bindFlags, MiscFlags miscFlags, ExtraFlags extraFlags) { Width = width; Height = height; MipLevels = mipLevels; ArraySize = arraySize; FormatID = formatID; Sampling = sampling; Usage = usage; BindFlags = bindFlags; MiscFlags = miscFlags; ExtraFlags = extraFlags; }
/// <summary> /// Initializes a new instance of the <see cref="Texture" /> class. /// </summary> /// <param name="target">The texture target.</param> /// <param name="colorSpace">The source image color space.</param> /// <param name="sampling">The sampling options.</param> internal Texture(GL target, ColorSpace colorSpace, Sampling sampling) { this.target = target; this.ColorSpace = colorSpace; this.Sampling = sampling; }