public void Theta1ComplexTest() { var data = new[] { new Complex(0.325809816971265, 0.370161570985216), new Complex(-0.554674516560841, 0.499945368673331), new Complex(-1.93056857428662, 2.34534826872622), new Complex(-0.1472793517103625, 0.1560224176074929), new Complex(0.198956036583271, -1.87317433564776), new Complex(0.000948623894881476, -0.0231214497788391), new Complex(-0.413480618291979, -2.501046888987470), new Complex(0.2310770688461198, -1.0933062123454492), new Complex(0.383535878655032, -0.123381469441342), new Complex(-0.0410955986444651, 0.0539153508370558), new Complex(0.3880648652198836, 0.1080708332301739), new Complex(0.3119095691176429, 0.1661628828111056), new Complex(1.42936113058871, 1.01544618991625), new Complex(0.0159107820654157, 0.0511556824774055), new Complex(1.333570576905667, 0.614655026222637), new Complex(1.0997563008807847, 0.1208498036545937), new Complex(-1.01814545441105, 2.53426831012354), new Complex(-0.000747703469610204, 0.00024075059847843), new Complex(-2.089398894953623, -0.338003060204557), new Complex(-2.031668534521739, -0.493468543237303), }; for (int i = 0; i < data.Length; i += 4) { var z = data[i]; var q = data[i + 1]; var th = Theta.θ1(z, q); var err = th - data[i + 2]; Assert.IsTrue(Complex.Abs(err) < 1e-14); var cfn = Theta.θ1ComplexForNome(q); th = cfn(z); err = th - data[i + 2]; Assert.IsTrue(Complex.Abs(err) < 1e-14); th = Theta.θ1(z, q.Real); err = th - data[i + 3]; Assert.IsTrue(Complex.Abs(err) < 1e-15); } }
public void Theta2ComplexTest() { var data = new[] { new Complex(-0.712045573932278, 1.30561516966583), new Complex(0.0115779438837883, 0.00215513498962569), new Complex(-1.02921651633888, -0.55663233114557), new Complex(0.0251305156397967, -0.0159972042786677), new Complex(-0.270601468194827, -0.958161202750493), new Complex(0.212623597863526, -0.480192562215063), new Complex(2.06182432952114, 0.605868394894129), new Complex(-0.018128943757431, 0.175402508876567), new Complex(-0.0161641166929001, 1.12406115610682), new Complex(0.0974889810203627, -0.317370944403016), }; var ans = new[] { "0.9510034016694605+0.7818307996124119 i", "0.4318298974220141-0.4811293513824665 i", "-3.491983713766145-1.639180977911250 i", "-0.4606794630399191-1.0510325356860531 i", "0.141664390294264-1.839493486453470 i", }; for (int i = 0; i < data.Length; i += 2) { var z = data[i]; var q = data[i + 1]; var th = Theta.θ2(z, q); var ex = Parse(ans[i / 2]); var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-14); var tf = Theta.θ2ComplexForNome(q); th = tf(z); err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-14); } }
public void Theta2ComplexDoubleTest() { var data = new[] { -0.712045573932278, 1.30561516966583, 0.0115779438837883, -1.02921651633888, -0.55663233114557, 0.0251305156397967, -0.270601468194827, -0.958161202750493, 0.212623597863526, 2.06182432952114, 0.605868394894129, -0.018128943757431, -0.0161641166929001, 1.12406115610682, 0.0974889810203627, }; var ans = new[] { "0.982419608291746+0.734637332793804 i", "0.47435925857122-0.39980828620516 i", "2.3339170647049-0.80428867268903 i", "0.004025373680221-0.5849390348420 i", "2.05576743007898+0.0323625056143800 i", }; for (int i = 0; i < data.Length; i += 3) { var z = new Complex(data[i], data[i + 1]); var q = data[i + 2]; var th = Theta.θ2(z, q); var ex = Parse(ans[i / 3]); var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-13); } }
public async Task <Theta> AddThetaAsync(Theta theta) { _context.Thetas.Add(theta); await _context.SaveChangesAsync(); return(theta); }
private void button3_Click(object sender, EventArgs e) { float Xc, Yc, a, b, Theta; EllipseRegression(out Xc, out Yc, out a, out b, out Theta); System.Drawing.Graphics graphics = this.CreateGraphics(); Matrix rotmatrix = new Matrix(); rotmatrix.RotateAt(Theta, new PointF(Xc, Yc)); graphics.Transform = rotmatrix; graphics.DrawEllipse(Pens.Red, Xc - a, Yc - b, 2 * a, 2 * b); //graphics.DrawLine(Pens.Red, Xc - 2, Yc, Xc + 2, Yc); graphics.DrawLine(Pens.Red, Xc - a, Yc, Xc + a, Yc); //graphics.DrawLine(Pens.Red, Xc, Yc - 2, Xc, Yc + 2); graphics.DrawLine(Pens.Red, Xc, Yc - b, Xc, Yc + b); rotmatrix.RotateAt(-Theta, new PointF(Xc, Yc)); graphics.Transform = rotmatrix; var fontFamily = new FontFamily("Times New Roman"); var font = new Font(fontFamily, 12, FontStyle.Regular, GraphicsUnit.Pixel); graphics.DrawString("Theta=" + Theta.ToString(), font, Brushes.Red, 10, 10); graphics.DrawString("Xc=" + Xc.ToString(), font, Brushes.Red, 10, 24); graphics.DrawString("Yc=" + Yc.ToString(), font, Brushes.Red, 10, 38); graphics.DrawString("a=" + (a * 2).ToString(), font, Brushes.Red, 10, 52); graphics.DrawString("b=" + (b * 2).ToString(), font, Brushes.Red, 10, 66); }
public GaussianNaiveBayes Estimate(Matrix input, Vector output) { // Algorithm used to calculate variance + mean : http://i.stanford.edu/pub/cstr/reports/cs/tr/79/773/CS-TR-79-773.pdf var distinctOutput = output.Distinct(); var nbFeatures = input.NbColumns; var nbClasses = distinctOutput.Count(); var classCount = new int[nbClasses]; var classPrior = new int[nbClasses]; var epsilon = 1e-9 * input.Variance().Max().Key.GetNumber(); Theta = Matrix.BuildEmptyMatrix(nbClasses, nbFeatures); Sigma = Matrix.BuildEmptyMatrix(nbClasses, nbFeatures); for (int i = 0; i < nbClasses; i++) { var ot = distinctOutput.Values[i]; var indexes = output.FindIndexes(ot); Matrix subMatrix = indexes.Select(_ => input.GetRowVector(_).Values).ToArray(); var kvp = UpdateMeanVariance(subMatrix); Theta.SetRow(kvp.Key, i); Sigma.SetRow(kvp.Value, i); classCount[i] = subMatrix.NbRows; } Sigma = Sigma.Sum(epsilon); CalculateClassPrior(output); return(this); }
public void Theta2ComplexAtZeroTest() { var data = new[] { new Complex(0.0115779438837883, 0.00215513498962569), new Complex(0.0251305156397967, -0.0159972042786677), new Complex(0.212623597863526, -0.480192562215063), new Complex(-0.018128943757431, 0.175402508876567), new Complex(0.0974889810203627, -0.317370944403016), }; var ans = new[] { "0.6582370796109659+0.0303389984653170 i", "0.8227835878337571-0.1180651209669994 i", "1.252099829145631-0.757243748784380 i", "1.1514971709760006+0.5030378061113643 i", "1.2808167514270764-0.5228813837190602 i", }; for (int i = 0; i < data.Length; i++) { var q = data[i]; var th = Theta.θ2(0, q); var ex = Parse(ans[i]); var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-15); } }
public void Theta2DoubleTest() { var data = new[] { -0.712045573932278, 0.0115779438837883, 0.496601444431198, -1.02921651633888, 0.0251305156397967, 0.409986239688389, -0.270601468194827, 0.212623597863526, 1.35096326526392, 2.06182432952114, 0.018128943757431, -0.3458068199639, -0.0161641166929001, 0.0974889810203627, 1.128018761735100, }; for (int i = 0; i < data.Length; i += 3) { var z = data[i]; var q = data[i + 1]; var th = Theta.θ2(z, q); var ex = data[i + 2]; var err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-14); var tf = Theta.θ2DoubleForNome(q); th = tf(z); err = th - ex; Assert.IsTrue(Complex.Abs(err) < 1e-14); } }
/// <summary> /// コンストラクタ /// </summary> public MainViewModel() { theta = Theta.GetInstance(); Mode = (int)ThetaMode.StillCaptureMode; Connect = new DelegateCommand(connectExecute, null); Release = new DelegateCommand(releaseExecute, null); }
public override int GetHashCode() { int hash = 1; if (Id != 0) { hash ^= Id.GetHashCode(); } if (relativePosition_ != null) { hash ^= RelativePosition.GetHashCode(); } if (relativeVelocity_ != null) { hash ^= RelativeVelocity.GetHashCode(); } if (Rcs != 0D) { hash ^= Rcs.GetHashCode(); } if (Movable != false) { hash ^= Movable.GetHashCode(); } if (Width != 0D) { hash ^= Width.GetHashCode(); } if (Length != 0D) { hash ^= Length.GetHashCode(); } if (Height != 0D) { hash ^= Height.GetHashCode(); } if (Theta != 0D) { hash ^= Theta.GetHashCode(); } if (absolutePosition_ != null) { hash ^= AbsolutePosition.GetHashCode(); } if (absoluteVelocity_ != null) { hash ^= AbsoluteVelocity.GetHashCode(); } if (Count != 0) { hash ^= Count.GetHashCode(); } if (MovingFramesCount != 0) { hash ^= MovingFramesCount.GetHashCode(); } return(hash); }
protected bool Equals(Greeks other) { return(Gamma.AlmostEqual(other.Gamma, 4) && Delta.AlmostEqual(other.Delta, 4) && Theta.AlmostEqual(other.Theta, 4) && Vega.AlmostEqual(other.Vega, 4) && Rho.AlmostEqual(other.Rho, 4) && RhoFx.AlmostEqual(other.RhoFx, 4) && Sigma.AlmostEqual(other.Sigma, 4)); }
public async Task <Theta> UpdateThetaAsync(Theta theta) { if (!_context.Thetas.Local.Any(c => c.Id == theta.Id)) { _context.Thetas.Attach(theta); } _context.Entry(theta).State = EntityState.Modified; await _context.SaveChangesAsync(); return(theta); }
private Fibonacci(Fibonacci previous, double angle) { Index = previous.Index + 1; Distance = Math.Sqrt(Index); Theta = previous.Theta + angle; var radians = Theta.DegreesToRadians(); X = Distance * Math.Cos(radians); Y = Distance * Math.Sin(radians); }
private void OnAdd() { Theta _theta = new Theta() { Name = NewThetaName }; NewThetaName = ""; repo.AddThetaAsync(_theta); Thetas.Add(_theta); }
/// <summary> /// Default hashcode implmentation, see https://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-overriding-gethashcode /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hash = 17; // Suitable nullity checks etc, of course :) hash = hash * 23 + Theta.GetHashCode(); hash = hash * 23 + Phi.GetHashCode(); return(hash); } }
///<summary> /// Customizes the string with a format provider ///</summary> ///<param name="format"></param> ///<param name="formatProvider"></param> ///<returns></returns> public string ToString(string format, IFormatProvider formatProvider) { CultureInfo culture = (CultureInfo)formatProvider ?? CultureInfo.CurrentCulture; if (string.IsNullOrEmpty(format)) { format = "G"; } return(R.ToString(format, culture) + culture.TextInfo.ListSeparator + " " + Theta.ToString(format, culture)); }
private void SetStartStatusToText() { float Rou, Theta; CameraManager.CalculateCameraHorizontal(_TimeToCreate, out Rou, out Theta); float Height = CameraManager.CalculateCameraVertical(_TimeToCreate); float Rotation = CameraManager.CalculateCameraRotation(_TimeToCreate); BeginRadiusText.text = Rou.ToString(); BeginDegreeText.text = Theta.ToString(); BeginHeightText.text = Height.ToString(); BeginRotationText.text = Rotation.ToString(); }
public override int GetHashCode() { unchecked { int hashCode = Gamma.GetHashCode(); hashCode = (hashCode * 397) ^ Delta.GetHashCode(); hashCode = (hashCode * 397) ^ Theta.GetHashCode(); hashCode = (hashCode * 397) ^ Vega.GetHashCode(); hashCode = (hashCode * 397) ^ Rho.GetHashCode(); hashCode = (hashCode * 397) ^ RhoFx.GetHashCode(); hashCode = (hashCode * 397) ^ Sigma.GetHashCode(); return(hashCode); } }
public string ToString(string format, IFormatProvider formatProvider) { CultureInfo culture = (CultureInfo)formatProvider; if (culture == null) { culture = CultureInfo.CurrentCulture; } if (format == null || format.Length == 0) { format = "G"; } return(R.ToString(format, culture) + culture.TextInfo.ListSeparator + " " + Theta.ToString(format, culture)); }
public void Theta3ComplexDoubleTest() { var data = new[] { 1, .5, .8, -0.029804108096716, 0.12673663794188, .5, 1, .8, -24.754831613744, 105.2655423467, 1, -2, .5, 141.53976744402, -78.927794100850, }; for (int i = 0; i < data.Length; i += 5) { var z = new Complex(data[i], data[i + 1]); var q = data[i + 2]; var ex = new Complex(data[i + 3], data[i + 4]); var th = Theta.θ3(z, q); var err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-12); } }
public void Theta4ComplexDoubleTest() { var data = new[] { 1, .5, .8, -2.2292262746206, 1.4720623460696, .5, 1, .8, -1.9162438634838, -0.33406441973926, 1, -2, .5, -421.90684150439, 64.81131918179, }; for (int i = 0; i < data.Length; i += 5) { var z = new Complex(data[i], data[i + 1]); var q = data[i + 2]; var ex = new Complex(data[i + 3], data[i + 4]); var th = Theta.θ4(z, q); var err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-13); } }
public Matrix PredictProbability(Matrix input) { var jointLogLikelihood = new Vector[ClassPriors.Count()]; for (int i = 0; i < ClassPriors.Count(); i++) { var kvp = ClassPriors.ElementAt(i); var jointi = System.Math.Log(kvp.Value); var nij = Sigma.GetRowVector(i).Multiply(System.Math.PI).Multiply(2.0).Log().Sum().GetNumber() * -0.5; var res = input.Substract(Theta.GetRowVector(i)).Pow(2).Div(Sigma.GetRowVector(i)).SumAllRows().Multiply(-0.5).Sum(nij); jointLogLikelihood[i] = res.Sum(jointi); } Matrix jointLogLikelihoodMatrix = jointLogLikelihood; jointLogLikelihoodMatrix = jointLogLikelihoodMatrix.Transpose(); var logProbX = jointLogLikelihoodMatrix.Logsumexp(); return(jointLogLikelihoodMatrix.Substract(logProbX).Exp()); }
/// <summary> /// Computes the probability of the prediction being True. /// </summary> /// <param name="x"></param> /// <returns></returns> public double PredictRaw(Vector x) { double prediction = 0d; this.Preprocess(x); if (KernelFunction.IsLinear) { prediction = Theta.Dot(x) + Bias; } else { for (int j = 0; j < X.Rows; j++) { prediction = prediction + Alpha[j] * Y[j] * KernelFunction.Compute(X[j, VectorType.Row], x); } prediction += Bias; } return(prediction); }
public void Theta1DoubleTest() { var data = new[] { .12478414350, .82872474670, .0000590523, -.32903686210, .95465479750, .0000000045, -.32701981860, .41588039490, -0.2933109256, .08385962364, .79913716820, 0.000176717, 1.4888543850, .22263345920, 1.4354035775, }; for (int i = 0; i < data.Length; i += 3) { var t = Theta.θ1(data[i], data[i + 1]); var e = data[i + 2]; Assert.IsTrue(Math.Abs(t - e) < 1e-10); var dfn = Theta.θ1DoubleForNome(data[i + 1]); t = dfn(data[i]); Assert.IsTrue(Math.Abs(t - e) < 1e-10); } }
/// <summary> /// Returns the point string value of this instance. /// </summary> /// <returns>A System.String containing this point.</returns> public override string ToString() { var radius = Radius.ToString(); var theta = Theta.ToString(); var phi = Phi.ToString(); var longStr = string.Format("{0} - {1}", radius, theta); var sep = false; if (longStr.IndexOfAny(new[] { ',', ';' }) > -1) { sep = true; } if (!sep && longStr.IndexOf(';') > -1) { const string quoteStr = "\"{0}\""; radius = string.Format(quoteStr, radius.Replace("\"", "\\\"")); theta = string.Format(quoteStr, theta.Replace("\"", "\\\"")); phi = string.Format(quoteStr, phi.Replace("\"", "\\\"")); } return(string.Format("{0} = {1}{2} {3} = {4}{2} {5} = {6}", PolarPoint.Symbols.RadiusSymbol, radius, sep ? ";" : ",", PolarPoint.Symbols.ThetaSymbol, theta, Symbols.PhiSymbol, phi)); }
public StepTable(double[] mainCoefficient, int[] basisIndex, double[] freeMember, double[][] restrictionCoefficient) { //Заполняем таблицу входными данными MainCoefficient = mainCoefficient; BasisIndex = basisIndex; FreeMember = freeMember; RestrictionCoefficient = restrictionCoefficient; //Вычисляем значение Value = FindValue(); //Вычисляем оценки дельта Delta = CalculateDelta(); //Заканчиваем вычисления, если все оценки дельта <= 0 FinalTable = Delta.All(e => e <= 0); if (FinalTable) { return; } //Рассчитываем индексы главного элемента P = Array.IndexOf(Delta, Delta.Max()); Theta = CalculateTheta(P); Q = Array.IndexOf(Theta, Theta.Where(e => e >= 0).Min()); }
public void Theta3ComplexTest() { var data = new[] { 1, .5, .8, .2, -8.5650514071151, 2.4686976173121, .5, 1, .8, .2, 163.66474018387, 61.293085451771, .5, 0, .5, .7, 2.3266061005072, 0.57989205450763, }; for (int i = 0; i < data.Length; i += 6) { var z = new Complex(data[i], data[i + 1]); var q = new Complex(data[i + 2], data[i + 3]); var ex = new Complex(data[i + 4], data[i + 5]); var th = Theta.θ3(z, q); var err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-14); var t3 = Theta.θ3ComplexForNome(q); th = t3(z); err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-14); } }
public void Theta3DoubleTest() { var data = new[] { 1, .8, 0.04246457514070379, .5, .8, 1.223823417425446, .5, .5, 1.484396862425167, }; for (int i = 0; i < data.Length; i += 3) { var z = data[i]; var q = data[i + 1]; var ex = data[i + 2]; var th = Theta.θ3(z, q); var err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-15); var t3 = Theta.θ3DoubleForNome(q); th = t3(z); err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-15); } }
public void Theta4DoubleTest() { var data = new[] { 1, .8, 0.8713168498521653, .5, .8, 0.02201388267155668, .5, .5, 0.411526533253406, }; for (int i = 0; i < data.Length; i += 3) { var z = data[i]; var q = data[i + 1]; var ex = data[i + 2]; var th = Theta.θ4(z, q); var err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-15); var t3 = Theta.θ4DoubleForNome(q); th = t3(z); err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-15); } }
public void Theta4ComplexTest() { var data = new[] { 1, .5, .8, .2, 0.11267273837782, 0.63114326027714, .5, 1, .8, .2, -149.86895286679, 53.695192284056, .5, 0, .5, .7, 0.5835418615326, -0.12747179582096, }; for (int i = 0; i < data.Length; i += 6) { var z = new Complex(data[i], data[i + 1]); var q = new Complex(data[i + 2], data[i + 3]); var ex = new Complex(data[i + 4], data[i + 5]); var th = Theta.θ4(z, q); var err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-13); var t4 = Theta.θ4ComplexForNome(q); th = t4(z); err = Complex.Abs(th - ex) / Complex.Abs(th); Assert.IsTrue(Complex.Abs(err) < 1e-13); } }