private static bool TestUniformSampler(Continuous sampleFunction, float minValue, float maxValue, out bool min, out bool max, out float sample) { bool inBounds = true; min = false; max = false; sample = float.NaN; for (int i = 0; i < UniformCount; i++) { sample = sampleFunction(); if ((sample < minValue) || (sample > maxValue)) { inBounds = false; break; } if (!min && (sample == minValue)) { min = true; } else if (!max && (sample == maxValue)) { max = true; } } return(inBounds); }
private static int[] SampleContinuous(Continuous sampleFunction, int binCount) { var bins = new int[binCount]; for (int i = 0; i < SampleCount; i++) { float sample = sampleFunction(); var index = (int)(sample * 10); if (index < binCount) { bins[index]++; } } return(bins); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ListSet.Expression != null) { targetCommand.AddParameter("ListSet", ListSet.Get(context)); } if (Counter.Expression != null) { targetCommand.AddParameter("Counter", Counter.Get(context)); } if (SampleInterval.Expression != null) { targetCommand.AddParameter("SampleInterval", SampleInterval.Get(context)); } if (MaxSamples.Expression != null) { targetCommand.AddParameter("MaxSamples", MaxSamples.Get(context)); } if (Continuous.Expression != null) { targetCommand.AddParameter("Continuous", Continuous.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
static void Main(string[] args) { double p = 0.6; int N = 10; int n = 100; int[] frequencies = Discret.Binomial(p, N, n); int[] xi = new int[11]; Console.WriteLine($"Вероятность успеха - {p}"); Console.WriteLine($"Количество испытаний - {N}"); Console.WriteLine($"Количество опытов - {n}"); Console.Write("Распределение - {"); for (int i = 0; i < frequencies.Length; i++) { xi[i] = i; Console.Write($"{frequencies[i]} "); } Console.Write("}\n"); double hiSquare = Statistics.GetPearsonsNumberForBinomialDistribution(xi, frequencies, 100, 10, p, out int k); Console.WriteLine($"Критерий Пирсона - {hiSquare}"); Console.WriteLine($"Количество степеней свободы - {k}"); Console.WriteLine("\n\n\n\n"); double average = 4; double standDif = 10; int n1 = 1000; Console.WriteLine($"Среднее - {average:f3}"); Console.WriteLine($"Стандартное отклонение - {standDif:f3}"); Console.WriteLine($"Количество опытов - {n1}"); Continuous.Normal(average, standDif, n1, out double[] averagesOfIntervals, out int[] freqs, out double h); Console.WriteLine("Середина\tЧастота"); for (int i = 0; i < averagesOfIntervals.Length; i++) { Console.WriteLine($"{averagesOfIntervals[i]:f3}\t\t{freqs[i]}"); } Console.WriteLine($"Критерий Пирсона - {Statistics.GetPearsonsNumberForNormalDistribution(averagesOfIntervals, freqs, n, h)}"); }
public StylusAcquisition(PolhemusController controller, Continuous continuous, Monitor monitor = null) { if (controller == null) throw new ArgumentNullException("controller"); if (continuous == null) throw new ArgumentNullException("continuous"); _controller = controller; _continuous = continuous; _monitor = monitor; _continuousMode = true; initialization(); ProgressChanged += new ProgressChangedEventHandler(sa_StylusProgressChanged); }