이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to find parameters of binomial distribution?
조회 수: 8 (최근 30일)
이전 댓글 표시
Dear all,
What code can I use in matlab to find the parameters of a binomial distribution? This question is very big. So I am restricting it to a specific situation.
X is binomiallly distributed with parameter n and fraction p. The parameter p is unknown.
What function in matlab can help me to find that parameter if for example it is known that X=randi(10,20,1); P(X<=4)=0.3?
Thank you in advance.
채택된 답변
Star Strider
2019년 1월 31일
If you have the Statsitics and Machine Learning Toolbox, see if the binofit (link) function will do what you want.
댓글 수: 15
Clarisha Nijman
2019년 1월 31일
Thank a lot Star,
I had also checked that option, but as I understand it just generally finds the cumulative distribution of that probablity distribution. That is not the function I am looking for. How to find the parameter if you know that the probability is for example P(X<=4)=0.3.
Star Strider
2019년 1월 31일
My pleasure.
I am still not certain what result you want.
Y = 4/20;
N = 20;
P = 0.3;
X = binoinv(Y,N,P)
X =
4.0000
Clarisha Nijman
2019년 1월 31일
Let me start with the way I understand the binoinv function works:
X is binomially distributed with N, P [N is number of trials, P is fraction of succeses]
F(k)=P(X<=k)=Y [F is cumlative distribution function, k is the actual number of sucesses, en Y is probability of the number of sucesses is less equal then k]
So binoinv computes the X, the limitting number of successes, such that F(k)=Y holds.
In my case every thing is known, except the P: The four other inputs are known: the N, the X, the k, and the Y are known. I cannot find a function in matlab to find the P
Star Strider
2019년 1월 31일
I am not certain what you want to do or what function would be most appropriate, because I do not completely understand the problem you want to solve.
One option for ‘inverting’ a function would be to use it with an optimization function, and solve for the variable you want.
For example using fminsearch:
Y = 4/20;
N = 20;
X = 6;
Pr = fminsearch(@(P) norm(binoinv(Y,N,P) - X), 1)
produces:
Pr =
0.399999999999999
Experiment to get the result you want.
Clarisha Nijman
2019년 1월 31일
The exact problem is:
I have a set of observations, X, and finding Q1, the first quartile (or 25th percentile) is not a problem.
Now I want to have the binomial distribution of the set of the observations less or equal then the first quartile (Q1). Given that the set of trials is known, I only need to find the the fraction (P)
Star Strider
2019년 2월 1일
I still do not understand what you want. I have no idea what ‘P’ is and how it relates to your problem.
I will delete my Answer few hours.
Clarisha Nijman
2019년 2월 1일
After reading and reading, it looks like the p is called the maximum likelihood. So the binofit mentioned by you seems to be the best solution. I am not really sure. I'll try to use that an see what it gives.
Star Strider
2019년 2월 1일
Thjat is the only option I believe is appropriate.
Post back with your results.
Clarisha Nijman
2019년 2월 1일
Thanks a lot Star,
Posting my results is not possible, it is a large data set of 360,000 observations! But I'll try to think of a small example that is can be verified easily.
Clarisha Nijman
2019년 2월 1일
De results are not good!
Can you correct me? I will write what I understood:
binofit, finds ..... the maximum likelihood estimate OF the probability of success .......
and with mle function you find the maximum likelihood estimate FOR the probability of succes?
Star Strider
2019년 2월 1일
It uses the mle (link) function to fit the distribution to your data. You can use it yourself to fit the binomial distributin to your data. Since mle, as is true of all nonlinear iterative parameter estimation methods, is sensitive to the initial parameter estimates, consider using mle with your data, and different initial parameter estimates to see if you can get a better fit.
I still do not understand what you are doing, or even if the binomial distribution would be appropriate for your data and experiment design. If it is not appropriate, that could be the reason you are having problems fitting it to your data.
Clarisha Nijman
2019년 2월 1일
I just wanted to know how to find the fracion of a large data set that is said to be binomially distributed. suppose X are 20 realization and binomially distributed.
X=randi(10,20,1) and X~bin(20,p),, Find p by using a matlab code.
Star Strider
2019년 2월 1일
For that problem, this appears to be the correct approach:
X=randi(10,20,1);
Px4 = nnz(X <= 4)/numel(X); % Single Probability
[P,Pci] = binofit(Px4, numel(X)) % Binomial Probability Of A ‘Px4’ Fraction Of ‘X’ Being <= 4, Those Being Defined As A ‘Success’
If you run this several times, you will get different results for each iteration, depending on the elements of ‘X’. and therefore the value of ‘Px4’.
Clarisha Nijman
2019년 2월 2일
That is it!!!!!!
the problem was the interpretation of the first parameter of the binofit function.
But now I understand, x is not the number of the succeses, but the probability of success in a given binomial trial based on the ACTUAL number of successes,
Once more thanks a lot!!!!
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)