コード例 #1
0
ファイル: StdStats.cs プロジェクト: franklzt/DataStruct
 /**
   * Plots the line segments connecting 
   * (<em>i</em>, <em>a</em><sub><em>i</em></sub>) to
   * (<em>i</em>+1, <em>a</em><sub><em>i</em>+1</sub>) for 
   * each <em>i</em> to standard draw.
   *
   * @param a the array of values
   */
  public static void plotLines(double[] a) {
      validateNotNull(a);
      int n = a.length;
      StdDraw.setXscale(-1, n);
      StdDraw.setPenRadius();
      for (int i = 1; i < n; i++) {
          StdDraw.line(i-1, a[i-1], i, a[i]);
      }
  }
コード例 #2
0
ファイル: StdStats.cs プロジェクト: franklzt/DataStruct
 /**
   * Plots the points (0, <em>a</em><sub>0</sub>), (1, <em>a</em><sub>1</sub>), ...,
   * (<em>n</em>-1, <em>a</em><sub><em>n</em>-1</sub>) to standard draw.
   *
   * @param a the array of values
   */
  public static void plotPoints(double[] a) {
      validateNotNull(a);
      int n = a.length;
      StdDraw.setXscale(-1, n);
      StdDraw.setPenRadius(1.0 / (3.0 * n));
      for (int i = 0; i < n; i++) {
          StdDraw.point(i, a[i]);
      }
  }