Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samyam81/mathematical-model
A curated collection of mathematical models spanning various disciplines, offering insights and tools for analysis, simulation, and understanding complex phenomena.
https://github.com/samyam81/mathematical-model
bayesian-inference bell-curve blackscholes gaussian-distribution java lotka-volterra lotka-volterra-model markov-chain mathematical-modelling mathematics
Last synced: 3 days ago
JSON representation
A curated collection of mathematical models spanning various disciplines, offering insights and tools for analysis, simulation, and understanding complex phenomena.
- Host: GitHub
- URL: https://github.com/samyam81/mathematical-model
- Owner: samyam81
- Created: 2024-05-22T06:34:07.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-23T04:05:47.000Z (8 months ago)
- Last Synced: 2024-05-23T07:43:31.585Z (8 months ago)
- Topics: bayesian-inference, bell-curve, blackscholes, gaussian-distribution, java, lotka-volterra, lotka-volterra-model, markov-chain, mathematical-modelling, mathematics
- Language: Java
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Mathematical-Model.
# Population Growth Simulator
This Java program simulates population growth using the logistic growth model and the Lotka-Volterra model. It generates random parameters for the growth models and simulates the growth over a specified period of time.
## Getting Started
To run the simulation, simply execute the `PredictTheGrowth.java` file in your Java environment. Ensure you have Java installed on your system.
```bash
javac PredictTheGrowth.java
java PredictTheGrowth
```## Overview
The program randomly generates parameters for two types of growth models:
### Logistic Growth Model
- Growth rate (r): Between 0 and 0.5
- Carrying capacity (K): Between 0 and 2000
- Initial population size (N0): Between 0 and 100
- Time step (dt): Between 0 and 0.5
- Total simulation time: Between 0 and 500It then simulates population growth using the logistic growth equation:
```
dN/dt = r * N * (1 - N / K)
```### Lotka-Volterra Model
- Prey birth rate (alpha): Between 0 and 0.5
- Predation rate coefficient (beta): Between 0 and 0.5
- Predator-prey interaction rate (delta): Between 0 and 0.5
- Predator death rate (gamma): Between 0 and 0.5It then simulates population dynamics using the Lotka-Volterra equations:
```
dx/dt = alpha * x - beta * x * y
dy/dt = delta * x * y - gamma * y
```## Bayesian Inference Simulation
This Java program implements Bayesian inference to update beliefs about the probability of grass being wet given observations about rain and sprinkler activity. Here's how it works:
- Prior probabilities (`pW`, `pR`, `pS`): These represent the initial beliefs about the probability of the grass being wet, the probability of rain, and the probability of the sprinkler being on, respectively.
- Conditional probabilities (`pWGivenR`, `pWGivenNR`, `pWGivenS`, `pWGivenNS`): These represent the likelihood of observing wet grass given different combinations of rain and sprinkler activity.
- Observation (`r`, `s`): These are boolean variables representing whether it rained (`r`) and whether the sprinkler was on (`s`).
- The `calculatePosteriorProbability` function uses Bayesian inference to update the prior beliefs based on the observed data.
- Finally, the program outputs the final posterior probability of the grass being wet given the observations.## Black-Scholes
This Java program calculates the price of a European call option using the Black-Scholes model. Here's how it works:
- The `blackScholesCall` function implements the Black-Scholes formula for pricing a call option.
- It takes parameters such as the current stock price (`s`), the strike price (`x`), the risk-free interest rate (`r`), the time to expiration (`t`), and the volatility (`v`).
- Inside the `main` function, random values are generated for these parameters within certain ranges.
- The `roundToFiveSignificantDigits` function rounds a given value to five significant digits.
- Using the generated random data, the program calculates the price of a European call option using the Black-Scholes formula and outputs the result.## Output
The simulation results are printed to the console, displaying the population size at each time step for both growth models. Additionally, a plot of the results can be implemented using appropriate plotting libraries.
## File Structure
- `PredictTheGrowth.java`: Contains the Java code for the population growth simulation.
- `BayesianInferenceSimulation.java`: Contains the Java code for the Bayesian inference simulation.
- `BlackScholes.java`: Contains the Java code for the Black-Scholes option pricing.## Author
This program was created by Samyam.81[https://github.com/samyam81].