X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev4%2FPages%2FBinomialSolver.xaml.cs;fp=dev4%2FPages%2FBinomialSolver.xaml.cs;h=1e1eb824a51357db221b0dc9bb5d7ea2a5919a08;hb=7b907758692783aad332a63a2a4084c0f2e34dcb;hp=84c26e8a824821242112fb41e9b281c1ed78f3af;hpb=60468a6671a33f5f9ec05e5be1c78f48b99f8e6b;p=psychlops%2Fsilverlight.git diff --git a/dev4/Pages/BinomialSolver.xaml.cs b/dev4/Pages/BinomialSolver.xaml.cs index 84c26e8..1e1eb82 100644 --- a/dev4/Pages/BinomialSolver.xaml.cs +++ b/dev4/Pages/BinomialSolver.xaml.cs @@ -15,6 +15,7 @@ namespace PsychlopsSilverlight4.Pages { public partial class BinomialSolver : ChildWindow { + System.Windows.Shapes.Line line; int func_selected; Psychlops.Solver.Constants.Func1 func1; Psychlops.Solver.Constants.Func2 func2; @@ -56,6 +57,13 @@ namespace PsychlopsSilverlight4.Pages chart1.DataContext = data; solver = new Psychlops.Solver.BinomialLikelihood(); + line = new Line(); + line.X1 = 0; + line.Y1 = 0; + line.X2 = ChartCanvas.ActualWidth; + line.Y2 = 0; + ChartCanvas.Children.Add(line); + OText.DataContext = OrdinateSlider; } public class Data { @@ -204,10 +212,55 @@ namespace PsychlopsSilverlight4.Pages this.UpdateLayout(); } - private void AbscissaSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) + private void RemoveConditionButton_Click(object sender, RoutedEventArgs e) { - solver.champ[0] = AbscissaSlider.Value; - reFunc(); + data.RemoveAt(data.Count-1); + this.UpdateLayout(); + } + + private void OrdinateSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + if (solver.champ[0] == 0.0) return; + int dir = 1, pdir, dirr=0, ii = 0; + double d = (maximum - minimum) * 0.25; + double refval = OrdinateSlider.Value; + double x1 = solver.champ[0], x2= x1 + d, v1, v2, tmp; + switch (func_selected) + { + case 1: + break; + case 2: + while (dirr < 32) + { + pdir = dir; + v1 = Math.Abs(refval - func2(x1, solver.champ[0], solver.champ[1])); + v2 = Math.Abs(refval - func2(x2, solver.champ[0], solver.champ[1])); + if (v1 > v2) + { + tmp = x2; + x1 = x2; + x2 = tmp + d; + dir = 1; + } + else + { + tmp = x1; + x2 = x1; + x1 = tmp - d; + dir = -1; + } + if (ii>32 || dir != pdir) { d /= 2; dirr++; ii = 0; } + ii++; + } + break; + case 3: + break; + } + + AbscissaSlider.Value = (x1+x2)/2.0; + Parameter0.Text = AbscissaSlider.Value.ToString(); + line.Y1 = refval * 200; + line.Y2 = refval * 200; } }