Hi All,
As a newbie, I have been trying to write a code on flipping a coin. More specifically, I write a simple code to simulate the outcomes of flipping a coin as 0 representing heads and 1 representing tails on an increasing number of trials as below:
forvalues i = 10(10)100 {
set obs `i'
g trial`i' = int(2*runiform())
However, what I was not able to do is to plot a line graph showing the frequency of each simulation vs the number of trials. For instance, the frequency of the tail is, say, 0.7 for 10 trials, 0.65 for 20 trials, and ...0.51 for 1000 simulations (as the number of trials increases, the frequency gets closer to .50). How can I draw a line graph showing each frequency of tails (or, heads) on the vertical axis and the number of trials on the horizontal axis?
Many thanks in advance.
Related Posts with Plotting a line graph of frequency of flipping a coin on different number of trials
Percentile Calculation Panel DataHi I have a panel data set from 1987Q1 to 2016Q4. I want to assign each observation using deciles. B…
Error r(3900) while running Latent Class AnalysisHello STATALIST group Can anyone tell me why I am getting the following error while running Latent…
How to generate a local list with numbers in a simple wayHi all, I have a simple question. Say I want to process filenames or variable names with consecutive…
Stata - reproducible research (in 2021)Stata's update to 17 is impressive and tempting (not least because of increased speed and improved i…
Finite Population specification for multi-level cross-classified models with repeated measuresHi all, I'm working with a three-level cross-classified model with repeated measures (i.e. multiple…
Subscribe to:
Post Comments (Atom)
0 Response to Plotting a line graph of frequency of flipping a coin on different number of trials
Post a Comment