Skip to content

Commit fad7df4

Browse files
committed
replace Array{Float64, x} with Vector and Matrix
1 parent 7d17172 commit fad7df4

31 files changed

+102
-102
lines changed

src/asm2000.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function asm2000(setting::RegressionSetting)::Dict
5757
end
5858

5959

60-
function asm2000(X::Array{Float64,2}, y::Array{Float64,1})::Dict
60+
function asm2000(X::Matrix{Float64}, y::Vector{Float64})::Dict
6161
n, p = size(X)
6262
h = floor((n + p - 1) / 2)
6363
ltsreg = lts(X, y)

src/atkinson94.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function atkinson94(setting::RegressionSetting; iters = nothing, crit = 3.0)::Di
5959
end
6060

6161
function atkinson94(
62-
X::Array{Float64,2},
63-
y::Array{Float64,1};
62+
X::Matrix{Float64},
63+
y::Vector{Float64};
6464
iters = nothing,
6565
crit = 3.0,
6666
)::Dict

src/atkinsonstalactiteplot.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function atkinsonstalactiteplot(
3434
end
3535

3636
function atkinsonstalactiteplot(
37-
X::Array{Float64,2},
38-
y::Array{Float64,1};
37+
X::Matrix{Float64},
38+
y::Vector{Float64};
3939
iters = nothing,
4040
crit = 3.0,
4141
)::Nothing
@@ -46,7 +46,7 @@ function atkinsonstalactiteplot(
4646
end
4747

4848
function generate_stalactite_plot(
49-
residuals_matrix::Array{Float64,2},
49+
residuals_matrix::Matrix{Float64},
5050
n::Int64,
5151
p::Int64,
5252
crit,

src/bacon.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Two methods V1 and V2 are defined in the paper which use Mahalanobis distance or
2424
- `method`: The distance method to use for selecting the points for initial subset
2525
"""
2626
function initial_basic_subset_multivariate_data(
27-
X::Array{Float64,2},
27+
X::Matrix{Float64},
2828
m::Int;
2929
method::String = "mahalanobis",
3030
)
@@ -53,7 +53,7 @@ It also guarantees that at least m indices are returned and that the selected in
5353
- `m`: The minimum number of points to include in the subset indices.
5454
- `distances`: The distances vector used for selecting minumum distance indices.
5555
"""
56-
function select_subset(X::Array{Float64,2}, m::Int, distances::Array{Float64})
56+
function select_subset(X::Matrix{Float64}, m::Int, distances::Array{Float64})
5757
rank_x = rank(X)
5858
sorted_distances = sortperm(distances)
5959
subset = sorted_distances[1:m]
@@ -88,7 +88,7 @@ This function performs the outlier detection for multivariate data according to
8888
- `alpha`: The quantile used for cutoff
8989
"""
9090
function bacon_multivariate_outlier_detection(
91-
X::Array{Float64,2},
91+
X::Matrix{Float64},
9292
m::Int;
9393
method::String = "mahalanobis",
9494
alpha::Float64 = 0.025,
@@ -146,7 +146,7 @@ This function computes the t distance for each point and returns the distance ve
146146
- `y`: The output vector
147147
- `subset`: The vector which denotes the points inside the subset, used to scale the residuals accordingly.
148148
"""
149-
function compute_t_distance(X::Array{Float64,2}, y::Array{Float64}, subset::Array{Int64})
149+
function compute_t_distance(X::Matrix{Float64}, y::Array{Float64}, subset::Array{Int64})
150150

151151
n, p = size(X)
152152

@@ -187,7 +187,7 @@ This function computes the initial subset having at least m elements which are l
187187
- `alpha`: The quantile used for cutoff
188188
"""
189189
function bacon_regression_initial_subset(
190-
X::Array{Float64,2},
190+
X::Matrix{Float64},
191191
y::Array{Float64},
192192
m::Int;
193193
method::String = "mahalanobis",
@@ -259,7 +259,7 @@ Billor, Nedret, Ali S. Hadi, and Paul F. Velleman. "BACON: blocked adaptive comp
259259
Computational statistics & data analysis 34.3 (2000): 279-298.
260260
"""
261261
function bacon(
262-
X::Array{Float64,2},
262+
X::Matrix{Float64},
263263
y::Array{Float64};
264264
m::Int,
265265
method::String = "mahalanobis",

src/basis.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ end
133133
```julia-repl
134134
julia> setting = createRegressionSetting(@formula(calls ~ year), phones);
135135
julia> designMatrix(setting)
136-
24×2 Array{Float64,2}:
136+
24×2 Matrix{Float64}:
137137
1.0 50.0
138138
1.0 51.0
139139
1.0 52.0
@@ -160,10 +160,10 @@ julia> designMatrix(setting)
160160
1.0 73.0
161161
```
162162
"""
163-
function designMatrix(setting::RegressionSetting)::Array{Float64,2}
163+
function designMatrix(setting::RegressionSetting)::Matrix{Float64}
164164
mf = ModelFrame(setting.formula, setting.data)
165165
mm = ModelMatrix(mf)
166-
return convert(Array{Float64,2}, mm.m)
166+
return convert(Matrix{Float64}, mm.m)
167167
end
168168

169169

@@ -182,7 +182,7 @@ end
182182
```julia-repl
183183
julia> setting = createRegressionSetting(@formula(calls ~ year), phones);
184184
julia> responseVector(setting)
185-
24-element Array{Float64,1}:
185+
24-element Vector{Float64}:
186186
4.4
187187
4.7
188188
4.7
@@ -209,9 +209,9 @@ julia> responseVector(setting)
209209
29.0
210210
```
211211
"""
212-
function responseVector(setting::RegressionSetting)::Array{Float64,1}
212+
function responseVector(setting::RegressionSetting)::Vector{Float64}
213213
mf = ModelFrame(setting.formula, setting.data)
214-
return convert(Array{Float64,1}, setting.data[:, mf.f.lhs.sym])
214+
return convert(Vector{Float64}, setting.data[:, mf.f.lhs.sym])
215215
end
216216

217217

@@ -233,7 +233,7 @@ julia> X, y = @extractRegressionSetting setting;
233233
julia> size(X)
234234
(24,2)
235235
julia> y
236-
24-element Array{Float64,1}:
236+
24-element Vector{Float64}:
237237
4.4
238238
4.7
239239
4.7
@@ -313,7 +313,7 @@ julia> find_minimum_nonzero([0.0, 0.0, 5.0, 1.0])
313313
1.0
314314
```
315315
"""
316-
function find_minimum_nonzero(arr::Array{Float64,1})
316+
function find_minimum_nonzero(arr::Vector{Float64})
317317
return minimum(filter(x -> x > 0, arr))
318318
end
319319

src/bch.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ end
7575

7676

7777
function bch(
78-
Xdesign::Array{Float64,2},
79-
y::Array{Float64,1};
78+
Xdesign::Matrix{Float64},
79+
y::Vector{Float64};
8080
alpha = 0.05,
8181
maxiter = 1000,
8282
epsilon = 0.000001,
@@ -98,7 +98,7 @@ function bch(
9898
c = (2.0 * (n + 2.0 * p)) / (n - 2.0 * p)
9999

100100
estimatedvariance = 0.0
101-
estimatedvariances = Array{Float64,1}(undef, 0)
101+
estimatedvariances = Vector{Float64}(undef, 0)
102102

103103
# Algorithm 2 - Step 0.a
104104
coordmeds = coordinatwisemedians(X)

src/bchplot.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function bchplot(
4242
end
4343

4444
function bchplot(
45-
Xdesign::Array{Float64,2},
46-
y::Array{Float64,1};
45+
Xdesign::Matrix{Float64},
46+
y::Vector{Float64};
4747
alpha = 0.05,
4848
maxiter = 1000,
4949
epsilon = 0.00001,

src/ccf.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Perform signed gradient descent for clipped convex functions for a given regress
1919
2020
# Arguments
2121
- `setting::RegressionSetting`: RegressionSetting object with a formula and dataset.
22-
- `starting_lambdas::Array{Float64,1}`: Starting values of weighting parameters used by signed gradient descent.
22+
- `starting_lambdas::Vector{Float64}`: Starting values of weighting parameters used by signed gradient descent.
2323
- `alpha::Float64`: Loss at which a point is labeled as an outlier (points with loss ≥ alpha will be called outliers).
2424
- `max_iter::Int64`: Maximum number of iterations to run signed gradient descent.
2525
- `beta::Float64`: Step size parameter.
@@ -81,7 +81,7 @@ Perform signed gradient descent for clipped convex functions for a given regress
8181
# Arguments
8282
- `X::Matrix{Float64}`: Design matrix of the linear model.
8383
- `y::Vector{Float64}`: Response vector of the linear model.
84-
- `starting_lambdas::Array{Float64,1}`: Starting values of weighting parameters used by signed gradient descent.
84+
- `starting_lambdas::Vector{Float64}`: Starting values of weighting parameters used by signed gradient descent.
8585
- `alpha::Float64`: Loss at which a point is labeled as an outlier. If unspecified, will be chosen as p*mean(residuals.^2), where residuals are OLS residuals.
8686
- `p::Float64`: Points that have squared OLS residual greater than p times the mean squared OLS residual are considered outliers.
8787
- `max_iter::Int64`: Maximum number of iterations to run signed gradient descent.
@@ -100,8 +100,8 @@ Barratt, S., Angeris, G. & Boyd, S. Minimizing a sum of clipped convex functions
100100
101101
"""
102102
function ccf(
103-
X::Array{Float64,2},
104-
y::Array{Float64,1};
103+
X::Matrix{Float64},
104+
y::Vector{Float64};
105105
starting_lambdas = nothing,
106106
alpha = nothing,
107107
p = 3,

src/cm97.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050

5151

5252

53-
function cm97(X::Array{Float64,2}, y::Array{Float64,1}; maxiter::Int = 1000)::Dict
53+
function cm97(X::Matrix{Float64}, y::Vector{Float64}; maxiter::Int = 1000)::Dict
5454

5555
n, p = size(X)
5656
pbar::Float64 = p / n

src/dataimage.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Computational Statistics & Data Analysis 43.4 (2003): 541-552.
4444
4545
"""
4646
function dataimage(
47-
dataMatrix::Array{Float64,2};
47+
dataMatrix::Matrix{Float64};
4848
distance = :mahalanobis,
4949
)::Matrix{RGBX{Float64}}
5050
d = nothing

0 commit comments

Comments
 (0)