Skip to content

dyells07/Simulation-Modeling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monte Carlo Pi Estimation

The Monte Carlo Pi Estimation is a simple program that uses the Monte Carlo method to estimate the value of pi. The program generates a large number of random points and determines the number of points that fall within a circle inscribed in a square. The ratio of the number of points within the circle to the total number of points generated is used to estimate the value of pi.

System Requirements

  • Windows or Linux operating system
  • C++ compiler
  • Graphics.h library

Installation and Setup

  1. Download and install a C++ compiler on your system.
  2. Download the graphics.h library and install it on your system.
  3. Download the Monte Carlo Pi Estimation program file (montecarlo.cpp) and save it to a directory of your choice.
  4. Compile the program using the following command:
    gcc -pi montecarlo.cpp -lstdc++ -lgraph
  5. On Windows, run the compiled executable file (pi.exe) from the command prompt or double-click on it to run it.
  6. On Linux, run the compiled executable file (pi.out) from the terminal using the following command:
    ./pi.out

Usage

After running the program, you will be prompted to enter the number of iterations to perform for the pi estimation. Enter a positive integer value and press Enter.

The program will display a circle inscribed in a square on the screen, with the center of the circle at (300, 300) and a radius of 200. The program will generate random points within the square and plot them on the screen. Points that fall within the circle will be colored green, while points that fall outside the circle will be colored red.

After all the points have been generated and plotted, the program will calculate the estimated value of pi based on the ratio of the number of points within the circle to the total number of points generated. The estimated value of pi will be displayed on the screen.

Four-Digit Poker Test

The Four-Digit Poker Test is a statistical test used to determine if a set of randomly generated numbers is independent or not. The test involves generating a large number of four-digit integers and counting the frequency of certain combinations of digits. The observed frequencies are then compared to the expected frequencies, and a chi-squared test is performed to determine if the differences between the observed and expected frequencies are significant.

How to Use

To use the Four-Digit Poker Test, follow these steps:

  1. Compile and run the program on your computer. The program requires the user to input the number of numbers generated, as well as the observed frequencies of the following combinations of digits:
    • Four different digits
    • Four of a kind
    • Three of a kind
    • One pair
    • Two pair
  2. After the user inputs the observed frequencies, the program calculates the expected frequencies based on the probabilities of each combination of digits occurring.
  3. The program then performs a chi-squared test on the observed and expected frequencies to determine if the generated random numbers are independent or not. If the calculated chi-squared value is less than or equal to the tabulated value for chi-squared, then the numbers are considered independent. Otherwise, they are considered dependent.

Interpreting Results

If the program determines that the generated random numbers are independent, this means that the numbers are truly random and do not depend on any previous numbers generated. If the numbers are dependent, this means that there is some pattern or correlation between the generated numbers, indicating that they are not truly random.

It is important to note that the Four-Digit Poker Test is not foolproof and can only detect certain types of non-randomness. In addition, the test may produce false positives or false negatives, depending on the quality of the random number generator used and the sample size.

References

Chemical Reaction Simulation User Manual

This program simulates the chemical reaction between two reactants (C1 and C2) to produce a product (C3).

less Copy code

Program Inputs

  • k1: Rate constant for the reaction between C1 and C2
  • k2: Rate constant for the decomposition of C3
  • c1(0): Initial concentration of C1
  • c2(0): Initial concentration of C2
  • c3(0): Initial concentration of C3
  • delta: Small increment of time
  • time: Total simulation time

Program Outputs

The program outputs the concentration of C1, C2, and C3 at each time increment, as well as a text file ("lab01.txt") containing the same data.

Graphing the Data

To graph the data, open the "lab01.txt" file in a spreadsheet program (such as Microsoft Excel or Google Sheets) and plot the concentration of each species over time.

About

how simulation works ?

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published