API Reference
Problems and results
ScalingCollapse.ScalingProblem Type
ScalingProblem(xs, ys, Ls; kwargs...)
ScalingProblem(xs, ys, es, Ls; kwargs...)Find the parameters of a scaling function that collapse the data ys(xs) of all system sizes Ls onto one master curve.
The constructor solves the problem right away: it scans p_space for minima of the quality function, refines the best one with Nelder–Mead and estimates the error of every free parameter. The results are stored in the returned object:
sp.optimal_ps::Vector{Float64}: the optimal values of the free parameters, in the order ofScalingCollapse.scaled_p_names(sp.sf)(fixed parameters are not included);sp.optimal_ps_error::Vector{Float64}: their errors (seeerrorbelow; zeros witherror=false);sp.minimum::Float64: the value of the quality function atoptimal_ps(lower is better).
The input is kept in sp.data, one ScalingCollapse.Data per system size, and the scaling function in sp.sf.
Use scaled_data to get the rescaled data, e.g. for a plot, and parameter_errors to compute errors with another method after the fit.
Data
Ls is a vector of integer system sizes. The x values xs, the y values ys and the optional y errors es can each be given as
a vector: the same values for every system size (typical for
xs, e.g. a common temperature grid);a vector of vectors: one vector per system size, so different sizes can have different x values and different numbers of points;
a matrix with one column or one row per system size. The orientation is inferred from
length(Ls); a square matrix is read column by column (with a warning).
ys can also contain Measurements (Measurements.jl), whose uncertainties are then used as es. If any error is nonzero, the quality functions use their error-weighted form.
The data of every system size are sorted by x. Within a system size the x values must be distinct, and all values must be finite. At least two system sizes are needed.
Keyword arguments
Scaling form
sf::ScalingFunction=ScalingFunction(:xy): the scaling function that rescales the data of every system size, seeScalingFunction. Withoutsf, all keywords that are not listed here are passed on toScalingFunction, sop_names=["T_c", "nu"], nu=1.0is short forsf=ScalingFunction(:x; p_names=["T_c", "nu"], nu=1.0)(two names select the preset:x, three names the preset:xy).dx::Vector{Float64}=[-Inf, Inf]: the window[x_min, x_max]of rescaled x values in which the collapse is measured. The quality function only compares the curves inside this window, intersected with the x range that all sizes cover. Choose it around the critical point, where the scaling form holds.
Search
p_space::Vector{<:AbstractRange}=[0.1:0.1:3.0, ...]: one range per free parameter. The quality function is evaluated on every point of this grid, a Nelder–Mead fit starts from every grid point that is lower than its neighbours, and the best result starts the final fit. All fits are bounded byp_space, so the optimum must lie inside it. The scan costsprod(length, p_space)evaluations.starting_ps: skip the scan and start the final fit at this point (one value per free parameter), or at each of several points (a vector of such vectors, e.g.[[2.25, 1.0], [2.3, 0.8]]; the fit with the lowest finite quality is kept). The fits are then not bounded byp_space. This is faster than a scan, but only finds the minimum close to the start.quality::QualityFunction=MultipleSplines(): the quality function of the final fit and of the error analysis. SeeMultipleSplines,Linear,SingleSplineandHoudayer.quality_scan::QualityFunction=MultipleSplines(scan_mode=true): the quality function of the scan. The default ignores error bars, which makes the scan more robust; there is rarely a reason to change it.optimizer::Optim.NelderMead: the Nelder–Mead configuration of every fit, including the initial simplex and the algorithm parameters. The default initial simplex,Optim.AffineSimplexer(a=0.025, b=0.1), moves every parameterpby0.1p + 0.025. For parameters on very different scales, useStepSimplexer.optimizer_options::Optim.Options=Optim.Options(): tolerances, iteration and time limits, tracing and callbacks of every fit, including the fits of the error analysis.verbose::Bool=false: log the progress of the fit.
Error analysis
error::Union{Bool,Symbol}=true: the method of the error analysis.trueor:profile(default): profile width. The parameter is displaced from its optimum, the other free parameters are re-fitted at every displacement, and the error is the larger of the two displacements (one on each side) at which the quality first reacheserror_thresholdtimes its minimum.:conditional: as:profile, but the other parameters stay at their optimum. This ignores correlations between the parameters and gives smaller or equal errors. With one free parameter both methods agree.:bootstrap: standard deviation of the parameters fitted ton_bootstrapsynthetic data sets, in which every y value is redrawn from a Gaussian with its error bar as width. Needs error bars.false: no error analysis.
error_threshold::Union{Real,Vector{<:Real}}=1.3: the factor by which the quality may exceed its minimum within the error of a parameter (:profileand:conditional); one number, or one per free parameter. Must be larger than 1.n_bootstrap::Integer=100: the number of synthetic data sets oferror=:bootstrap(at least 2).rng::AbstractRNG=Random.default_rng(): the random number generator oferror=:bootstrap. Pass a seeded one, e.g.Random.Xoshiro(42), for reproducible errors.
Error analysis in detail
The profile and conditional errors are widths defined by a threshold on the quality, not standard deviations with a known coverage: the threshold is not calibrated, and correlations between data points (e.g. curves computed from the same Monte Carlo samples) are not taken into account. The profile accounts for correlations between the parameters.
Profile. The re-fitted parameters stay inside p_space; the profiled parameter does not. The crossing closest to the fit is used, so the error is a local width. Every inner fit uses optimizer and optimizer_options. With an affine initial simplex (the default), it is followed by a second fit whose initial steps are the conditional errors of the re-fitted parameters, which resolves quality valleys much narrower than the affine steps; any other initial simplex is used alone. If the profile finds a lower quality than minimum inside p_space, the fit is re-optimized from there and the analysis restarts (with a warning, up to 3 times), so optimal_ps and minimum can change. When the restarts run out, all errors are NaN. A lower quality outside p_space sets the error of that parameter to NaN and warns that p_space may be too narrow.
Profile and conditional. An error is NaN (with a warning) if the quality never reaches the threshold, or becomes undefined (no overlap of the rescaled data within dx) before.
Bootstrap. Every synthetic data set is fitted with Nelder–Mead from optimal_ps, inside p_space. optimal_ps and minimum stay those of the original data. The method assumes Gaussian, independent errors. Fits without a finite quality are dropped (with a warning); if more than 10% are dropped, all errors are NaN. The bootstrap costs about n_bootstrap fits, and its errors scatter between random seeds by a relative amount of about 1/sqrt(2(n_bootstrap - 1)): about 7% for 100 samples, enough for one significant digit. Use 500 or more for a reliable second digit.
Examples
# Binder cumulant: rescale x only, U(T, L) = F((T - T_c) L^(1/ν))
sp = ScalingProblem(Ts, binder, Ls;
sf=ScalingFunction(:x; p_names=["T_c", "nu"]),
p_space=[2.0:0.02:2.5, 0.5:0.1:1.5],
dx=[-2.0, 2.0],
)
sp.optimal_ps, sp.optimal_ps_error
# magnetization with error bars: M(T, L) = L^(-β/ν) F((T - T_c) L^(1/ν))
ScalingProblem(Ts, mag, mag_err, Ls; sf=ScalingFunction(:xy; p_names=["T_c", "nu", "beta"]))
# susceptibility, with ν fixed: χ(T, L) = L^(γ/ν) F((T - T_c) L^(1/ν))
ScalingProblem(Ts, chi, Ls; sf=ScalingFunction(:xny; p_names=["T_c", "nu", "gamma"], nu=1))
# no scan: start at a guess, with bootstrap errors
ScalingProblem(Ts, binder, binder_err, Ls;
sf=ScalingFunction(:x; p_names=["T_c", "nu"]),
starting_ps=[2.27, 1.0],
error=:bootstrap, n_bootstrap=500, rng=Random.Xoshiro(1),
)
# configure Nelder–Mead
using ScalingCollapse: Optim
ScalingProblem(Ts, binder, Ls;
sf=ScalingFunction(:x; p_names=["T_c", "nu"]),
optimizer=Optim.NelderMead(initial_simplex=StepSimplexer([0.002, 0.05])),
optimizer_options=Optim.Options(iterations=5_000, time_limit=60.0),
)ScalingCollapse.scaled_data Function
scaled_data(sp::ScalingProblem[, ps]; splines=false) -> (xs, ys, es, Ls)Rescale the data of sp with the scaling function sp.sf and the free parameters ps (default: sp.optimal_ps). Returns one vector per system size, in the order of the sizes given to ScalingProblem:
xs::Vector{Vector{Float64}}: rescaled x values (sorted);ys::Vector{Vector{Float64}}: rescaled y values;es::Vector{Vector{Float64}}: rescaled y errors (zeros without error bars);Ls::Vector{Int}: the system sizes.
The result contains all data points, also those outside the window sp.dx.
With splines=true (only for the MultipleSplines quality function), three more vectors are returned: xvals, yvals and evals hold, for every system size, the sp.quality.N_steps evaluation points in the window that the quality function compares, the interpolated y values there (as used by the quality function, before normalization), and the linearly interpolated errors.
Examples
using CairoMakie
xs, ys, es, Ls = scaled_data(sp)
fig = Figure()
ax = Axis(fig[1, 1])
for (x, y, L) in zip(xs, ys, Ls)
scatterlines!(ax, x, y; label="L = $L")
end
axislegend(ax)
figScaling
ScalingCollapse.ScalingFunction Type
ScalingFunction(preset::Symbol=:xy; p_names, relative=false, <name>=value, ...)
ScalingFunction(f::Function; p_names, <name>=value, ..., x_scale, y_scale)
ScalingFunction(p_names::Vector{String}; kwargs...)The scaling form of a ScalingProblem: how the data of one system size are rescaled for given values of the scaling parameters.
Presets
The presets rescale x around a critical point p1 with the correlation length exponent p2, and optionally y with a power of L:
| preset | x is rescaled to | y is rescaled to | typical observable |
|---|---|---|---|
:x | (x - p1) * L^(1/p2) | y | dimensionless: Binder cumulant, ξ/L |
:xy | (x - p1) * L^(1/p2) | y * L^(p3/p2) | y ∼ L^(-p3/p2): order parameter (β) |
:xny | (x - p1) * L^(1/p2) | y * L^(-p3/p2) | y ∼ L^(p3/p2): susceptibility (γ) |
Errors are rescaled like y. :xy is the default. Two p_names without a preset select :x, three select :xy.
Custom scaling functions
Any other scaling form is a function f(d::ScalingCollapse.Data, p1, p2, ...) that receives the data d of one system size and the values of all parameters (also the fixed ones) and returns the rescaled data as a new ScalingCollapse.Data (see ScalingCollapse.Data). It must not modify d. Give the parameter names with p_names (or only their number with N_parameters), and describe the scaling with x_scale and y_scale for display. To make your own scaling form available as a preset symbol, add a method to ScalingCollapse.handle_preset.
Keyword arguments
p_names::Vector{String}: the names of the parameters (default:"p1","p2", ...). They name the parameters in the output and select parameters to fix.<name>=value: fix the parameter<name>(one ofp_names) tovalue. A fixed parameter is not fitted, has no entry inp_space,starting_ps,optimal_psoroptimal_ps_error, and is passed to the scaling function with its fixed value.relative::Bool=false: withtrue, the presets rescale x relative to the critical point,(x - p1)/p1 * L^(1/p2)(e.g. with the reduced temperature(T - T_c)/T_c); this was the default up to version 0.2. A windowdxof the relative form equalsdx .* p1in the absolute form, which also works forp1 ≤ 0. Only for presets.x_scale::String,y_scale::String: the rescaling of x and y as text, used to display the problem. The presets set them.N_parameters::Int: the number of parameters of a customf, ifp_namesis not given.f::Function: replace the function of a preset, keeping its parameter names andx_scale/y_scale(the function must take as many parameters as the preset).
Examples
ScalingFunction(:x; p_names=["T_c", "nu"]) # Binder cumulant
ScalingFunction(:x; p_names=["T_c", "nu"], nu=1.0) # ν fixed to 1
ScalingFunction(:xy; p_names=["T_c", "nu", "beta"]) # magnetization
ScalingFunction(:xny; p_names=["T_c", "nu", "gamma"]) # susceptibility
ScalingFunction(:x; p_names=["T_c", "nu"], relative=true)
# custom: logarithmic shift of y, as for the specific heat of the 2D Ising model
function log_shift(d::ScalingCollapse.Data, T_c, nu, a)
xs = @. (d.xs - T_c) * d.L^(1 / nu)
ys = @. d.ys - a * log(d.L)
return ScalingCollapse.Data(d.L, xs, ys, d.es)
end
ScalingFunction(log_shift; p_names=["T_c", "nu", "a"], nu=1.0,
x_scale="(T - T_c) * L^(1/nu)", y_scale="C - a * log(L)")ScalingCollapse.handle_preset Function
ScalingCollapse.handle_preset(::Val{preset}; kwargs...) -> (f, p_names, x_scale, y_scale)Return the definition of the ScalingFunction preset preset. Add a method to define a new preset, which ScalingFunction(preset; kwargs...) then accepts like the built-in ones, including p_names and fixed parameters.
The method receives the keywords given to ScalingFunction and returns a tuple of
f: the scaling functionf(d::ScalingCollapse.Data, p1, p2, ...) -> ScalingCollapse.Data;p_names::Vector{String}: the default parameter names, usually overridden bykwargs[:p_names];x_scale::String,y_scale::String: the rescaling of x and y as text, for display.
Examples
using ScalingCollapse
# x rescaled with L^(1/nu), y shifted by a log(L)
function log_shift(d::ScalingCollapse.Data, x_c, nu, a)
xs = @. (d.xs - x_c) * d.L^(1 / nu)
ys = @. d.ys - a * log(d.L)
return ScalingCollapse.Data(d.L, xs, ys, d.es)
end
function ScalingCollapse.handle_preset(::Val{:log_shift}; kwargs...)
p_names = get(kwargs, :p_names, ["x_c", "nu", "a"])
x_scale = "(x - $(p_names[1])) * L^(1/$(p_names[2]))"
y_scale = "y - $(p_names[3]) * log(L)"
return log_shift, p_names, x_scale, y_scale
end
sf = ScalingFunction(:log_shift; p_names=["T_c", "nu", "a"], nu=1.0)ScalingCollapse.Data Type
ScalingCollapse.Data(L, xs, ys[, es])The data of one system size L: x values xs, y values ys and y errors es (zeros if omitted). ys can instead be a vector of Measurements, which is split into values and errors. The constructor sorts the points by x and stores the absolute values of the errors.
ScalingProblem stores one Data per system size, and custom scaling functions receive and return Data (see ScalingFunction).
Fields
L::Int: the system sizexs::Vector{Float64}: the x values, sortedys::Vector{Float64}: the y valueses::Vector{Float64}: the y errors
ScalingCollapse.n_parameters Function
ScalingCollapse.n_parameters(sf::ScalingFunction)The number of free (not fixed) parameters of sf.
ScalingCollapse.scaled_p_names Function
ScalingCollapse.scaled_p_names(sf::ScalingFunction)The names of the free (not fixed) parameters of sf, in the order of p_space, starting_ps, optimal_ps and optimal_ps_error.
ScalingCollapse.fixed_p_names Function
ScalingCollapse.fixed_p_names(sf::ScalingFunction)The names of the fixed parameters of sf.
Quality
ScalingCollapse.MultipleSplines Type
MultipleSplines(; interp=:pchip, N_steps=100, weight_density=true, scan_mode=false)The default quality function. It interpolates the rescaled data of every system size separately and measures how much the interpolated curves differ.
How it works
The curves are compared at N_steps evenly spaced points x_k in the window where all rescaled sizes overlap (intersected with dx). With the interpolated values y_l(x_k) of system size l, normalized so that all of them lie between 0 and 1 (and the errors scaled alike), the quality is
without error bars: the variance across system sizes, averaged over the points,
S = 1/N_steps Σ_k var_l(y_l(x_k));with error bars: the error-weighted squared deviation from the mean over system sizes,
S = Σ_k Σ_l ρ_l (y_l(x_k) - ȳ(x_k))² / (e_l(x_k)² + ē(x_k)²) / (N_steps Σ_l ρ_l),where
e_lis the linearly interpolated error of sizel,ē = sqrt(Σ_l e_l²) / nthe error of the meanȳof thensizes, andρ_lthe number of data points of sizelper unit of rescaled x in the window (or 1 withweight_density=false).
Since the curves are compared on a fixed set of points, the quality changes smoothly with the parameters, also for data on uniform grids (see Linear for the alternative). The normalization makes the quality independent of the scale of y, which matters when y is rescaled with a power of L.
Keyword arguments
interp::Symbol=:pchip: the interpolation of every system size.:pchip(default): monotone piecewise-cubic Hermite interpolation (Fritsch–Carlson). It never overshoots between data points, so noisy points on irregular x grids do not make the curve oscillate. A local extremum of the curve always lies on a data point, so a peak is cut off at its highest data point.:cubic: cubic interpolating spline (Dierckx.jl). More accurate for noise-free data, especially for master curves with peaks or several extrema, but it oscillates for noisy data on irregular grids. Needs at least 4 data points per system size.
N_steps::Int=100: the number of points at which the curves are compared.weight_density::Bool=true: with error bars, weight every system size by its density of data points in the window, so that sizes with many points count more.scan_mode::Bool=false: ignore the error bars (always use the unweighted form). This is the setting of the defaultquality_scanofScalingProblem.
ScalingCollapse.Linear Type
Linear()Quality function that measures the distance of every data point to the line between its neighbours, with the points of all system sizes merged.
How it works
All rescaled data points in the window where all sizes overlap (intersected with dx) are sorted by x. Every point i except the first and the last is compared with the linear interpolation ȳ_i between its left and right neighbour, which usually belong to other system sizes. The quality is the mean squared deviation,
S = 1/(n - 2) Σ_i (y_i - ȳ_i)²,or, with error bars, the mean of (y_i - ȳ_i)² / (e_i² + w_l² e_{i-1}² + w_r² e_{i+1}²), with the interpolation weights w_l and w_r of the neighbours. This was the default quality function up to version 0.2.
Limitations
The quality is piecewise: it jumps whenever scaled points of different sizes swap order in x (the neighbour of a third point changes from one size to the other) and whenever a point enters or leaves the window. It also dips where the scaled x grids of the sizes line up: near-coincident points of different sizes are compared with each other without interpolation error. On uniformly gridded data this gives false minima. For example:
percolation data on a grid uniform in
(p - 1/2) L^{0.7}: the quality changes abruptly at exactlyp_c = 1/2, where every size has a point atx = 0, and has its lowest profile minimum near the commensurateν = 1/0.7instead of near the trueν = 4/3;2D Ising Binder cumulant on a uniform temperature grid (
L = 8to64): minimized overT_c, the quality oscillates by about ±50% every 0.02 inν, with 19 local minima forνin[0.8, 1.1].
Houdayer and SingleSpline show the same kind of ruggedness. For uniformly gridded data, prefer MultipleSplines, which compares smooth interpolations of every size and gives a smooth quality, and check a fit by scanning the quality around it with residuals.
ScalingCollapse.SingleSpline Type
SingleSpline(; N_knots=0)Quality function that fits one smoothing spline to the rescaled data of all system sizes and measures the deviation of the data points from it.
How it works
All rescaled data points in the window where all sizes overlap (intersected with dx) are fitted with a natural cubic least-squares spline (KissSmoothing.jl). Its knots lie at evenly spaced quantiles of these points, so the spline keeps its flexibility when the scaling stretches or compresses the x axis. The quality is the mean squared deviation of the points from the spline, divided by their squared errors if error bars are given.
N_knots sets the number of knots; the default 0 uses one knot per 5 data points in the window (at least 2).
Limitations
Points entering or leaving the window change the fitted spline abruptly, so on uniformly gridded data the quality is rugged like that of Linear. MultipleSplines gives a smooth quality.
ScalingCollapse.Houdayer Type
Houdayer()Quality function of Houdayer & Hartmann, Phys. Rev. B 70, 014418 (2004). It is biased on coarse data grids (see below) and therefore not recommended.
How it works
Following Houdayer & Hartmann, Phys. Rev. B 70, 014418 (2004), for every scaled data point (x_ij, y_ij) of system size i in the overlap interval, the master curve is approximated by a weighted linear least-squares fit to the two data points of every other system size that bracket x_ij. The overlap interval is the window covered by all sizes, intersected with dx. With the fit value Y_ij and its variance dY²_ij, the quality is
S = 1/N Σ_ij (y_ij - Y_ij)² / (e_ij² + dY²_ij).If no error bars are given, all weights are set to 1.
Known bias
The linear fit misses the curvature of the master curve between the bracketing points. The error this causes grows with the square of the spacing of the scaled data points, which is largest for the biggest system size. A larger ν compresses the scaled x axis, shrinks this spacing, and thereby lowers S, so on coarse data grids the fitted ν comes out too large. For example, on noise-free synthetic data with 4 sizes and 41 points each (only about 5 of the largest size lie in the interval), ν came out 2-3% too large; with 161 points per size, 0.1%. The bias vanishes as the grid is refined. Linear and MultipleSplines do not show it.
Ruggedness
The bracketing data points change discontinuously as scaled points of different sizes pass each other, so the quality jumps and has many shallow local minima on uniformly gridded data, like Linear (see its docstring). MultipleSplines gives a smooth quality.
ScalingCollapse.QualityFunction Type
ScalingCollapse.QualityFunctionAbstract supertype of the quality functions, which measure how well the rescaled data of all system sizes collapse onto one curve: MultipleSplines (the default), Linear, SingleSpline and Houdayer. Lower values mean a better collapse.
A quality function is a callable struct qf(sp::ScalingProblem, ps; check_bounds=false) that returns a Float64 for the free parameters ps. It rescales every Data in sp.data with sp.sf.f(d, ps...), compares the curves within the overlap of all sizes intersected with sp.dx, and returns Inf if that interval is empty, or if check_bounds=true and ps lies outside sp.p_space. A new quality function can be defined in the same way and passed as quality to ScalingProblem.
Errors and landscapes
ScalingCollapse.parameter_errors Function
parameter_errors(sp::ScalingProblem; method, error_threshold, n_bootstrap, rng)Compute the errors of the optimal parameters of the solved problem sp, without changing sp. Use it to compare error methods, or to add errors to a fit made with error=false. Returns one error per free parameter, in the order of ScalingCollapse.scaled_p_names(sp.sf).
The keywords are those of the ScalingProblem constructor and default to the settings stored in sp. method takes the values of the error keyword except false; it defaults to sp.error, or to :profile if sp was fitted with error=false. The fits of the analysis use the optimizer settings of sp.
The bootstrap (method=:bootstrap) advances rng (sp.rng by default). Pass a seeded one, e.g. rng=Random.Xoshiro(1), for reproducible errors; for the same rng state, the errors equal those of a problem constructed with the same keywords.
If the profile (method=:profile) finds a lower quality than sp.minimum, sp is not at a minimum, and parameter_errors throws an ErrorException. parameter_errors! re-optimizes the fit in that case.
Examples
using Random
sp = ScalingProblem(xs, ys, es, Ls; error=false)
σ_profile = parameter_errors(sp)
σ_conditional = parameter_errors(sp; method=:conditional)
σ_bootstrap = parameter_errors(sp; method=:bootstrap, n_bootstrap=500, rng=Xoshiro(1))ScalingCollapse.parameter_errors! Function
parameter_errors!(sp::ScalingProblem; method, error_threshold, n_bootstrap, rng)Like parameter_errors, but store the errors in sp.optimal_ps_error and the keywords in sp (method in sp.error), as if sp had been constructed with them. Returns a copy of the errors.
If the profile finds a lower quality than sp.minimum, the fit is re-optimized from there (with a warning) and the analysis restarts, as in the constructor, so sp.optimal_ps and sp.minimum can change.
ScalingCollapse.residuals Function
residuals(sp::ScalingProblem; p_space, N_steps=51, dims) -> (p_space, S)Evaluate the quality function sp.quality on a grid of free parameters, e.g. to plot the quality landscape around a fit or to check that a minimum is not a numerical artifact.
Returns the ranges of the active dimensions and the array S of quality values, with one axis per active dimension: S[i, j, ...] belongs to p_space[1][i], p_space[2][j], ... The parameters of the other dimensions stay at their values in sp.optimal_ps. The parameters are not checked against the p_space of sp.
Keyword arguments
dims::Vector{Int}=1:n: the indices of the active free parameters (in the order ofScalingCollapse.scaled_p_names(sp.sf)), e.g.dims=[1, 2]for a 2D cut through a problem with three free parameters.p_space: one range per free parameter; the ranges of inactive dimensions are ignored. By default, every active parameter spansoptimal_ps ± 3 optimal_ps_errorwithN_stepspoints, which needs finite, nonzero errors.N_steps::Int=51: the number of points per dimension of the defaultp_space.
Examples
sp = ScalingProblem(Ts, chi, Ls; sf=ScalingFunction(:xny; p_names=["T_c", "nu", "gamma"]))
# 3D landscape: length(ps) == 3, size(S) == (51, 51, 51)
ps, S = residuals(sp)
# 2D cut in T_c and nu, with gamma at its optimum
ps, S = residuals(sp; dims=[1, 2], N_steps=101)
# 1D cut along nu on a given range
ps, S = residuals(sp; dims=[2], p_space=[0:0, 0.8:0.005:1.2, 0:0])Optimizer
ScalingCollapse.StepSimplexer Type
StepSimplexer(steps)Initial Nelder–Mead simplex with one step per free parameter: vertex i + 1 is the starting point with steps[i] added to parameter i. Pass it as optimizer=Optim.NelderMead(initial_simplex=StepSimplexer(steps)) to ScalingProblem when the free parameters live on very different scales.
The default Optim.AffineSimplexer(a=0.025, b=0.1) moves every parameter p by 0.1p + 0.025, which follows the value of the parameter rather than its scale in the problem: it moves a critical point p_c ≈ 0.5 by 0.075, even if the data only span a window of width 1e-3 around it.
steps must have one finite, nonzero entry per free parameter, in the order of ScalingCollapse.scaled_p_names(sf) (fixed parameters have no entry). A step of the order of the expected error of the parameter is a good choice. Steps for which the quality is not finite are halved, as for any initial simplex. In the profile error analysis, the inner fits use only the steps of the parameters they re-fit. (With an affine simplex, the inner fits are instead followed by a second fit with one step per re-fitted parameter equal to its conditional error.)
Examples
using ScalingCollapse: Optim
ScalingProblem(xs, ys, Ls;
sf=ScalingFunction(:x; p_names=["p_c", "nu"]),
p_space=[0.48:0.002:0.52, 0.8:0.1:2.0],
optimizer=Optim.NelderMead(initial_simplex=StepSimplexer([1e-3, 0.05])),
)Index
ScalingCollapse.DataScalingCollapse.HoudayerScalingCollapse.LinearScalingCollapse.MultipleSplinesScalingCollapse.QualityFunctionScalingCollapse.ScalingFunctionScalingCollapse.ScalingProblemScalingCollapse.SingleSplineScalingCollapse.StepSimplexerScalingCollapse.fixed_p_namesScalingCollapse.handle_presetScalingCollapse.n_parametersScalingCollapse.parameter_errorsScalingCollapse.parameter_errors!ScalingCollapse.residualsScalingCollapse.scaled_dataScalingCollapse.scaled_p_names