简体   繁体   中英

MATLAB: How can I plot the Probit function?

I wrote the following code to plot the Logit function where beta = 1.

beta = 1
e(:,1) = 0:0.01:1;
e(:,2) = log(e(:,1)./(1-e(:,1)))+beta;
plot(e(:,2),e(:,1))

As far as I can tell that looks fine, but I don't know how to add the Probit function. I understand how to put to plots in one figure, but I don't understand how to generate data from this distribution. Is there some convenient way to do this in MATLAB?

Ultimately I'm looking to create something like the following, in which it can be seen that the Probit and Logit are very similar.

概率论与Logit

beta = 1
e(:,1) = 0:0.01:1;
e(:,2) = log(e(:,1)./(1-e(:,1)))+beta; % logit fn + beta
e(:,3) = sqrt(2) * erfinv(2*e(:,1) - 1) ; % probit fn
plot(e(:,1),e(:,2:3))

As suggested by @patrick if you have the "Machine learning and statistic toolbox" it would be cleaner to use the norminv function, that is replace the 4th line by:

e(:,3) = norminv(e(:,1)) ; % probit fn

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM