Getting regression weights from histogram

조회 수: 2 (최근 30일)
Matthias Schiedeck
Matthias Schiedeck 2022년 6월 9일
편집: Alan Stevens 2022년 6월 9일
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

채택된 답변

Alan Stevens
Alan Stevens 2022년 6월 9일
편집: Alan Stevens 2022년 6월 9일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by