Getting regression weights from histogram

2 vues (au cours des 30 derniers jours)
Matthias Schiedeck
Matthias Schiedeck le 9 Juin 2022
Modifié(e) : Alan Stevens le 9 Juin 2022
Hello!
I have generated several data points from a given function in order to fit another curve. Although the input (concentrations) is always different, some output values (temperatures) seem to occur more frequently (see histogram). When fitting my new curve with these temperature values, frequently occurring values (e.g. 350 - 400 °C) are more heavily weighted than others (e.g. 500 - 550 °C).
Therefore I want to do a weighted regression/fit, where I give a little more weight to less frequently occurring values and less weight to more frequently occuring values (since it's not experimental data but just calculation results). I'm looking for something like the red curve drawn on the histogram. Unfortunately, I can't do this by hand since it's too many data points.
Is there a way to get something like the red curve from histogram data?
Thanks,
Matthias

Réponse acceptée

Alan Stevens
Alan Stevens le 9 Juin 2022
Modifié(e) : Alan Stevens le 9 Juin 2022
Something like this perhaps?
% Dummy data
N = 1000;
M = N/40;
T = randn(N,1);
h = histogram(T,M);
W = max(h.Values)-h.Values;
x = min(T):(max(T)-min(T))/(M-1):max(T);
hold on
plot(x,W)
xlabel('T')
NB You will probably want to scale the weights as obtained above, so that you don't get a zero weight.
You could use interp1 if you need a separate weight for each temperature.

Plus de réponses (0)

Catégories

En savoir plus sur Fit Postprocessing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by