Other Functions

beta_bins()

SubjectiveScalesModels.beta_binsFunction
beta_bins(n::Int=10)

A Simple function that produces a vector of bins boundaries, useful for histograms. It adds bins on the left and right tails for extreme values (0 and 1), convenient for data suited for OrderedBeta models.

julia> beta_bins(3)
6-element Vector{Float64}:
 -0.3333333333333333
  2.220446049250313e-16
  0.3333333333333335
  0.6666666666666667
  1.0
  1.3333333333333333

julia> beta_bins([0, 0.5, 0.2, 0.6, 0.8, 1, 0.5, 0.4])
6-element Vector{Float64}:
 -0.3333333333333333
  2.220446049250313e-16
  0.3333333333333335
  0.6666666666666667
  1.0
  1.3333333333333333
source

data_rescale()

SubjectiveScalesModels.data_rescaleFunction
data_rescale(x; old_range=[minimum(x), maximum(x)], new_range=[0, 1])

Rescale a variable to a new range. Can be used to normalize a variable between 0 and 1.

Danger

This function is currently used internally and might be moved to another package. Avoid using it directly.

Arguments

  • x: Vector to rescale.
  • old_range: Old range of the vector to rescale (will be taken by default from the minimum and maximum value of x).
  • new_range: Range to rescale x to. By default, [0-1].

Examples

julia> data_rescale([1, 2, 3])
3-element Vector{Float64}:
 0.0
 0.5
 1.0

julia> data_rescale([1, 2, 3]; old_range=[1, 6], new_range=[1, 0])
3-element Vector{Float64}:
 1.0
 0.8
 0.6
source