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
mediation analysisDear experts, I want to do a mediation analysis using the type of data like below. exp is the exposu…
Bilateral trade gravity model specificationDear community, I want to estimate a gravity model to examine the impact of interstate wars on bila…
Checking for global maximum in LCA (latent class analysis)Hi team, I am looking for help in assessing the usability of my LCA model, fit using gsem. I have 1…
Collapsing observations in longitudinal dataHi all, I had a question about how to approach my data problem. I start with a file that is child-p…
collapsing repeated cross section data to panel for first stage IV , then storing the result to run second stage on repeated cross sectionHere, due to nature of my data I need to collapse my repeated cross section data to panel data ( the…
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