Probability using binomial probability?

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?

 Akzeptierte Antwort

the cyclist
the cyclist am 24 Nov. 2015
Bearbeitet: the cyclist am 25 Nov. 2015

0 Stimmen

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:

4 Kommentare

Ronan
Ronan am 25 Nov. 2015
The predict function requires an object for the input which you obtained from fitlm. I don't have the Statistics and Machine Learning Toolbox. So if you use polyfit it dosent return an object. How do you use predict after using polyfit?
Here is a version that only uses core MATLAB:
% Data
distance = [0.2 0.4 0.5 0.6]';
price = [500 600 400 300]';
% Fit a linear model
[coeff] = polyfit(distance,price,1);
% Get predicted price over a range of distances
dq = (0 : 0.05 : 1)';
pq = coeff(2) + dq*coeff(1);
% Plot the data and the fit
figure
hold on
scatter(distance,price);
plot(dq,pq,'r')
xlabel('Distance')
ylabel('Price')
Ronan
Ronan am 25 Nov. 2015
Bearbeitet: Ronan am 25 Nov. 2015
Thank you for your help. I don't understand the line pq = coeff(2) + dq*coeff(1); but I assume its some kind of alternative to the prediction function? I was looking at another equation also for probability that uses logistic regression.
F(x) = 1/{1+e^{-(beta_0 + beta_1*x)}}
where beta_0 is the intercept and beta_1 is the regression coefficient.
There is a good example of the probability of students passing exams, where hours of study is proportional to pass rates if you are interested.
https://en.wikipedia.org/wiki/Logistic_regression
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

the cyclist
the cyclist am 23 Nov. 2015

0 Stimmen

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?
You might use ksdensity.

5 Kommentare

Ronan
Ronan am 24 Nov. 2015
Sorry, i forgot to mention that each point in the field has two values, a quantity and a distance. So say for example you have a set of hotels with price and distance away from the city centre. The closer to the city centre you are the more expensive the hotel. For the set of 400 hotels, I wanted to generate a bell curve showing highest price at the peak. Then for each hotel I want to generate the probability of it being the best hotel assuming that the best to worst hotel is most expensive to least expensive. And best hotel is the closest and worst hotel is the furthest. I m just not sure how to approach this from a probability point of view.
the cyclist
the cyclist am 24 Nov. 2015
Bearbeitet: the cyclist am 24 Nov. 2015
So far, I don't see any probability in this problem. Everything you have described is deterministic. Here is a subset of your data:
distance = [0.1 0.2 0.4 1.0];
price = [500 400 200 100];
The best hotel is the first one (closest and priciest); the worst hotel is the last one (farthest and cheapest).
There is no "probability of being best".
What am I missing? Can you take this toy example and describe what the output should look like, and what I'm not understanding?
so say if the most ideal city has the most expensive hotel at the closest distance. but if you were to take different cities where the most expensive hotel isn't always the closest. e.g. the data varies in each city. so for example,
distance = [0.2 0.4 0.5 0.6]
price = [500 600 400 300]
So for each city you have anomalies that don't always make it certain but you use probability to identify best hotel.
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.
Ronan
Ronan am 24 Nov. 2015
yes, so this is effectively what I m trying to do. I was using the cost of the hotels just as an example. So if you had quality of the hotel instead that would be fine.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 23 Nov. 2015

Kommentiert:

am 25 Nov. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by