![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172235/image.png)
Probability using binomial probability?
3 次查看(过去 30 天)
显示 更早的评论
Suppose I have a field of points, where I want to find the most likely location of a point. If I have 400 points then obviously I have a 1/400 chance of finding that point. However if I assume that the points closer to the centre are more likely, is it coherent to suggest that I should use binomial probability. So I could just choose the closest distance but i want a dynamic way of telling how likely a point is in the correct location with varying distances. I don't have a whole lot of practise with probability so I m not really sure if this is right?
0 个评论
采纳的回答
the cyclist
2015-11-24
编辑:the cyclist
2015-11-25
From the preceding discussion, it sounds like you want a model that predicts price from distance. Here is some code that will do that.
% Data
distance = [0.2 0.4 0.5 0.6]';
price = [500 600 400 300]';
% Fit a linear model
mdl = fitlm(distance,price);
% Get predicted price over a range of distances
dq = (0 : 0.05 : 1)';
pq = predict(mdl,dq);
% Plot the data and the fit
figure
hold on
scatter(distance,price);
plot(dq,pq,'r')
xlabel('Distance')
ylabel('Price')
This code requires the Statistics and Machine Learning Toolbox. If you don't have that, you can use
[coeff] = polyfit(distance,price,1); % EDITED (to correct outputs)
to get the parameters of the linear model, and plot accordingly.
Here is the plot created by the code:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172235/image.png)
4 个评论
the cyclist
2015-11-25
The polyfit function is fitting the data to a line, which is the same thing as the fitlm function was doing. The line
pq = coeff(2) + dq*coeff(1);
is taking the coefficients of that fit, and calculating the price for a range of distance values. That is the "prediction" of price, given distance.
Since you don't have the Stats toolbox, you do not have a whole range of other modeling/fitting tools. You could write your own logistic fit (or maybe there is one in core MATLAB). But you would do the same thing. Fit the data to a model, then "predict" price from distance, given the fitted parameters.
更多回答(1 个)
the cyclist
2015-11-23
I'm afraid I don't understand the endpoint goal.
Do you mean that you have a field of points, with locations, and you want to know the probability of the location of another point taken from a similar sample?
5 个评论
the cyclist
2015-11-24
OK, so we're inching toward a complete description of the problem.
It's still not perfectly clear how to use probability -- I actually think you might mean statistics -- to solve this. You somehow need to generate a formula that takes you from these two measures to the one that truly measures quality (worst -- best).
If you actually had a quality measure of these hotels (e.g. star ratings) ...
stars = [4.3 4.4 3.7 3.2]
then you could build a mathematical model for estimating quality, based on the data.
Otherwise, I don't see a good way to solve the problem.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Price and Analyze Financial Instruments 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!