[Scilab-users] simulated binomial is shifted to the left

classic Classic list List threaded Threaded
3 messages Options
Heinz Nabielek Heinz Nabielek
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] simulated binomial is shifted to the left

When I compare Monte-Carlo simulated binomial distributions with the respective analytical binomial distributions, the histplot of the simulated ones is shifted to the left. What am I doing wrong?
Heinz


SciLab code:
p=[0.1176471    0.2352941    0.0588235    0.3882353    0.2]; N=100;
for i=1:5;histplot(0:60,grand(1,10000,"bin",N,p(i)),style=i);plot2d(binomial(p(i),N),style=i,rect=[0 0 60 .175]);end;

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

shifted simulated binomial.pdf (13K) Download Attachment
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: simulated binomial is shifted to the left

Defining an appropriate x-axis support for plot2d and binomial helps:

 

// START OF CODE

clf;

p=[0.1176471    0.2352941    0.0588235    0.3882353    0.2];

N=100;

for i=1:5;

    histplot(0:60,grand(1,10000,"bin",N,p(i)),style=i);

    x = linspace(-0.5,N-0.5,N+1)

    plot2d(x,binomial(p(i),N),style=i,rect=[0 0 60 .175]);

end;

// END OF CODE

 

Regards,

Rafael

 

From: users [mailto:[hidden email]] On Behalf Of Heinz Nabielek
Sent: Sunday, September 24, 2017 12:52 AM
To: Users mailing list for Scilab <[hidden email]>
Subject: [Scilab-users] simulated binomial is shifted to the left

 

When I compare Monte-Carlo simulated binomial distributions with the respective analytical binomial distributions, the histplot of the simulated ones is shifted to the left. What am I doing wrong?
Heinz


SciLab code:
p=[0.1176471    0.2352941    0.0588235    0.3882353    0.2]; N=100;
for i=1:5;histplot(0:60,grand(1,10000,"bin",N,p(i)),style=i);plot2d(binomial(p(i),N),style=i,rect=[0 0 60 .175]);end;


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Heinz Nabielek Heinz Nabielek
Reply | Threaded
Open this post in threaded view
|

Re: simulated binomial is shifted to the left

Hi Rafael:
Beautiful. Works like a charm. Thank you so very much....
IMHO, the code shows how to Monte-Carlo simulate discrete distributions that you never find described in such a simple way in statistics textbooks.
Heinz


On 24.09.2017, at 10:45, Rafael Guerra wrote:

> Defining an appropriate x-axis support for plot2d and binomial helps:
>  
> // START OF CODE
> clf;
> p=[0.1176471    0.2352941    0.0588235    0.3882353    0.2];
> N=100;
> for i=1:5;
>     histplot(0:60,grand(1,10000,"bin",N,p(i)),style=i);
>     x = linspace(-0.5,N-0.5,N+1);
>     plot2d(x,binomial(p(i),N),style=i,rect=[0 0 60 .175]);
> end;
> // END OF CODE
>  
> Regards,
> Rafael
>  
> From: users [mailto:[hidden email]] On Behalf Of Heinz Nabielek
> Sent: Sunday, September 24, 2017 12:52 AM
> To: Users mailing list for Scilab <[hidden email]>
> Subject: [Scilab-users] simulated binomial is shifted to the left
>  
> When I compare Monte-Carlo simulated binomial distributions with the respective analytical binomial distributions, the histplot of the simulated ones is shifted to the left. What am I doing wrong?
> Heinz
>
>
> SciLab code:
> p=[0.1176471    0.2352941    0.0588235    0.3882353    0.2]; N=100;
> for i=1:5;histplot(0:60,grand(1,10000,"bin",N,p(i)),style=i);plot2d(binomial(p(i),N),style=i,rect=[0 0 60 .175]);end;

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users