Skip to content

Commit 266306c

Browse files
committed
rfac: Create separate files for random values in examples to maintain consistency
1 parent cffa713 commit 266306c

File tree

10 files changed

+6035
-83
lines changed

10 files changed

+6035
-83
lines changed

examples/Histogram/arrayValues.swift

Lines changed: 1000 additions & 0 deletions
Large diffs are not rendered by default.

examples/Histogram/main.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ import Foundation
66
var filePath = "examples/Reference/"
77
let fileName = "_20_histogram"
88

9-
var x = [Float]()
10-
var mean: Float = 100
11-
var deviation: Float = 15
12-
let numberOfSamples = 10000
13-
14-
for _ in 1...numberOfSamples {
15-
let x1 = Float.random(in: 0.0...1.0)
16-
let x2 = Float.random(in: 0.0...1.0)
17-
let z1 = sqrt(-2 * log(x1))*cos(2*Float.pi*x2)
18-
x.append(z1*deviation + mean)
19-
}
20-
219
var agg_renderer = AGGRenderer()
2210
var svg_renderer = SVGRenderer()
2311

examples/HistogramStacked/arrayValues.swift

Lines changed: 2001 additions & 0 deletions
Large diffs are not rendered by default.

examples/HistogramStacked/main.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@ import Foundation
66
var filePath = "examples/Reference/"
77
let fileName = "_22_histogram_stacked"
88

9-
var x = [Float]()
10-
var y = [Float]()
11-
var mean1: Float = 100
12-
var mean2: Float = 150
13-
var deviation: Float = 15
14-
let numberOfSamples = 10000
15-
16-
for _ in 1...numberOfSamples {
17-
let x1 = Float.random(in: 0.0...1.0)
18-
let x2 = Float.random(in: 0.0...1.0)
19-
let z1 = sqrt(-2 * log(x1))*cos(2*Float.pi*x2)
20-
x.append(z1*deviation + mean1)
21-
}
22-
23-
for _ in 1...numberOfSamples {
24-
let x1 = Float.random(in: 0.0...1.0)
25-
let x2 = Float.random(in: 0.0...1.0)
26-
let z1 = sqrt(-2 * log(x1))*cos(2*Float.pi*x2)
27-
y.append(z1*deviation + mean2)
28-
}
29-
309
var agg_renderer = AGGRenderer()
3110
var svg_renderer = SVGRenderer()
3211

examples/HistogramStackedStep/arrayValues.swift

Lines changed: 2001 additions & 0 deletions
Large diffs are not rendered by default.

examples/HistogramStackedStep/main.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@ import Foundation
66
var filePath = "examples/Reference/"
77
let fileName = "_23_histogram_stacked_step"
88

9-
var x = [Float]()
10-
var y = [Float]()
11-
var mean1: Float = 100
12-
var mean2: Float = 150
13-
var deviation: Float = 15
14-
let numberOfSamples = 10000
15-
16-
for _ in 1...numberOfSamples {
17-
let x1 = Float.random(in: 0.0...1.0)
18-
let x2 = Float.random(in: 0.0...1.0)
19-
let z1 = sqrt(-2 * log(x1))*cos(2*Float.pi*x2)
20-
x.append(z1*deviation + mean1)
21-
}
22-
23-
for _ in 1...numberOfSamples {
24-
let x1 = Float.random(in: 0.0...1.0)
25-
let x2 = Float.random(in: 0.0...1.0)
26-
let z1 = sqrt(-2 * log(x1))*cos(2*Float.pi*x2)
27-
y.append(z1*deviation + mean2)
28-
}
29-
309
var agg_renderer = AGGRenderer()
3110
var svg_renderer = SVGRenderer()
3211

examples/HistogramStep/arrayValues.swift

Lines changed: 1000 additions & 0 deletions
Large diffs are not rendered by default.

examples/HistogramStep/main.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ import Foundation
66
var filePath = "examples/Reference/"
77
let fileName = "_21_histogram_step"
88

9-
var x = [Float]()
10-
var mean: Float = 100
11-
var deviation: Float = 15
12-
let numberOfSamples = 10000
13-
14-
for _ in 1...numberOfSamples {
15-
let x1 = Float.random(in: 0.0...1.0)
16-
let x2 = Float.random(in: 0.0...1.0)
17-
let z1 = sqrt(-2 * log(x1))*cos(2*Float.pi*x2)
18-
x.append(z1*deviation + mean)
19-
}
20-
219
var agg_renderer = AGGRenderer()
2210
var svg_renderer = SVGRenderer()
2311

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var x: [Float] = [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,
2+
11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,
3+
21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,
4+
31.0,32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,
5+
41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,
6+
51.0,52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,
7+
61.0,62.0,63.0,64.0,65.0,66.0,67.0,68.0,69.0,70.0,
8+
71.0,72.0,73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,
9+
81.0,82.0,83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,
10+
91.0,92.0,93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0]
11+
12+
var y: [Float] = [4.2631893,6.7059126,7.628232,13.637427,12.858896,5.223231,4.931411,18.70801,20.677948,18.627672,
13+
26.065609,24.355444,29.97152,37.28073,32.56613,24.098684,35.154667,43.39316,32.20861,37.989525,
14+
43.83518,45.219807,46.259842,38.398857,55.497612,58.803986,49.28604,57.87717,51.318546,62.452984,
15+
70.639145,63.72518,74.699104,63.28241,66.87369,62.109608,82.99158,66.95266,72.871765,78.30503,
16+
84.085526,80.38328,79.867546,87.68558,84.84651,84.61169,99.71762,105.01222,93.15355,98.913765,
17+
106.22638,95.59192,110.08125,100.77485,100.153076,111.85222,106.19889,115.38333,110.08667,123.81017,
18+
113.95746,121.79921,135.6522,130.51619,124.21184,140.87405,137.61543,128.48271,139.2247,137.32285,
19+
133.78604,146.28679,142.77173,140.72011,156.08202,158.30095,161.65813,163.28464,158.83165,153.05223,
20+
171.18262,155.08517,157.45909,166.7446,165.89272,166.97362,181.70923,174.7019,179.49031,182.05493,
21+
188.49632,191.17195,179.43036,182.68005,199.61313,183.62427,191.4581,194.72885,201.94327,191.91583]
22+
23+
var y1: [Float] = [0.8951454,13.443565,14.943378,11.152573,10.7133255,16.666685,14.834021,20.997272,20.767658,18.72945,
24+
27.692139,16.558588,19.298468,20.404104,25.613815,34.902985,26.127216,38.04979,32.093063,33.906956,
25+
35.42842,45.711555,42.18284,38.277866,55.14482,51.929714,45.873447,57.64733,55.464817,57.729126,
26+
59.896496,57.075554,59.345497,65.057076,79.281425,70.71545,76.69398,66.37727,73.215576,84.493416,
27+
73.54135,81.27777,78.14973,81.74306,89.889534,84.555466,99.51872,88.17887,107.97927,102.32298,
28+
106.034424,94.93776,105.55484,114.083305,110.25257,107.61554,106.48296,121.73368,126.99797,111.57737,
29+
115.465546,128.73634,129.44887,136.52638,125.7861,140.10326,133.41217,134.16756,145.59415,136.13039,
30+
141.89613,143.89456,141.61139,152.64307,148.26999,158.00577,157.71556,146.77061,158.42757,156.60875,
31+
160.87129,161.30185,175.61731,162.53177,177.35092,175.31349,175.53702,175.13135,179.48592,171.04482,
32+
172.12508,181.02628,183.85524,195.0799,187.77693,191.59532,185.63396,186.24928,199.14784,191.93817]

examples/ScatterPlot/main.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,12 @@ import SVGRenderer
55
var filePath = "examples/Reference/"
66
let fileName = "_19_scatter_plot"
77

8-
var x = [Float]()
9-
var y = [Float]()
10-
11-
var x1 = [Float]()
12-
var y1 = [Float]()
13-
14-
for index in 1...100 {
15-
x.append(Float(index))
16-
y.append(Float(index*2) + Float.random(in: -10...10))
17-
}
18-
19-
for index in 1...100 {
20-
x1.append(Float(index))
21-
y1.append(Float(index) + Float.random(in: -10...10))
22-
}
23-
248
var agg_renderer = AGGRenderer()
259
var svg_renderer = SVGRenderer()
2610

2711
var scatterPlot = ScatterPlot<Float,Float>(width: 1000, height: 1000)
2812
scatterPlot.addSeries(x, y, label: "Plot 1", startColor: .gold, endColor: .blue, scatterPattern: .circle)
29-
scatterPlot.addSeries(x1, y1, label: "Plot 2", color: .green, scatterPattern: .star)
13+
scatterPlot.addSeries(x, y1, label: "Plot 2", color: .green, scatterPattern: .star)
3014
scatterPlot.plotTitle = PlotTitle("SCATTER PLOT")
3115
scatterPlot.plotLabel = PlotLabel(xLabel: "X-AXIS", yLabel: "Y-AXIS")
3216

0 commit comments

Comments
 (0)