NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

High Performance Simulation Using Java 2
====================================
There are 2 types of random generators in Java: pseudorandom and secure. Pseudorandom generators are transforming a seed into a new portion of pseudorandom data based on some formula. Secure random generators are using some machine specific sources of actually random events (file/socket access, for example) to generate its data.
Secure random generators:
should be used only when cryptographically strong random data is required
are slow
could be waiting for external events (“stuck”) if you have requested a lot of random data (Linux /dev/random is an example of such generator)

ThreadLocalRandom implementation details:
======================================
Internally it does not use an AtomicLong seed from Random. Instead it uses an ordinary long.
You can not create an instance of ThreadLocalRandom yourself, because its constructor is not public. Instead you should use its static factory ThreadLocalRandom.current(). This factory method queries internal ThreadLocal<ThreadLocalRandom>
It is CPU-cache aware, so it uses 8 long dummy fields for padding, thus pushing anything else out of its 64 byte L1 cache line
ThreadLocalRandom single thread op runs 3 times faster than that of java.util.Random - uncontended CAS operations are still not free!
Like the global Random generator used by the Math class, a ThreadLocalRandom is initialized with an internally generated seed that may not otherwise be modified.

Back to Simulation
==================
Discrete event simulation event driven VS Continuous Simulation activity driven
Discrete Event Simulation Ingredients:
System State
Clock
Events List
Random Number Generators
System Stats
Ending Condition

The main loop of a discrete-event simulation is something like this:
Start
Initialize Ending Condition to FALSE.
Initialize system state variables.
Initialize Clock (usually starts at simulation time zero).
Schedule an initial event (i.e., put some initial event into the Events List).
“Do loop” or “while loop”[edit]
While (Ending Condition is FALSE) then do the following:
Set clock to next event time.
Do next event and remove from the Events List.
Update statistics.
End
Generate statistical report.

Monte-Carlo Methods / Simulation in Finance
======================================
The advantage of Monte Carlo methods over other techniques increases as the dimensions (sources of uncertainty) of the problem increase
In finance, the Monte Carlo method is used to simulate the various sources of uncertainty that affect the value of the instrument, portfolio or investment in question, and to then calculate a representative value given these possible values of the underlying inputs - Covering all conceivable real world contingencies in proportion to their likelihood."
Monte Carlo Methods are used for personal financial planning. For instance, by simulating the overall market, the chances of a 401(k) allowing for retirement on a target income can be calculated. As appropriate, the worker in question can then take greater risks with the retirement portfolio or start saving more money.
Monte Carlo Methods are used for portfolio evaluation.[17] Here, for each sample, the correlated behaviour of the factors impacting the component instruments is simulated over time, the resultant value of each instrument is calculated, and the portfolio value is then observed. As for corporate finance, above, the various portfolio values are then combined in a histogram, and the statistical characteristics of the portfolio are observed, and the portfolio assessed as required.
Discrete event simulation can be used in evaluating a proposed capital investment's impact on existing operations. Here, a "current state" model is constructed. Once operating correctly, having been tested and validated against historical data, the simulation is altered to reflect the proposed capital investment. This "future state" model is then used to assess the investment, by evaluating the improvement in performance (i.e. return) relative to the cost (via histogram as above); it may also be used in stress testing the design.
Many problems in mathematical finance entail the computation of a particular integral (for instance the problem of finding the arbitrage-free value of a particular derivative). In many cases these integrals can be valued analytically, and in still more cases they can be valued using numerical integration, or computed using a partial differential equation (PDE). However when the number of dimensions (or degrees of freedom) in the problem is large, PDEs and numerical integrals become intractable, and in these cases Monte Carlo methods often give better results.
For more than three or four state variables, formulae such as Black Scholes (i.e. analytic solutions) do not exist, while other numerical methods such as the Binomial options pricing model and finite difference methods face several difficulties and are not practical. In these cases, Monte Carlo methods converge to the solution more quickly than numerical methods, require less memory and are easier to program. For simpler situations, however, simulation is not the better solution because it is very time-consuming and computationally intensive.

A stochastic investment model tries to forecast how returns and prices on different assets or asset classes, (e. g. equities or bonds) vary over time. Stochastic models are not applied for making point estimation rather interval estimation and they use different stochastic processes. Investment models can be classified into single-asset and multi-asset models. They are often used for actuarial work and financial planning to allow optimization in asset allocation or asset-liability-management (ALM)
The random variables are usually constrained by historical data, such as past market returns.
"Stochastic" means being or having a random variable. A stochastic model is a tool for estimating probability distributions of potential outcomes by allowing for random variation in one or more inputs over time. The random variation is usually based on fluctuations observed in historical data for a selected period using standard time-series techniques. Distributions of potential outcomes are derived from a large number of simulations (stochastic projections) which reflect the random variation in the input(s)
A statistical analysis of the results can then help determine the probability that the portfolio will provide the desired performance. Stochastic projection tools are used to compare the distribution of outcomes under different financial planning
strategies.

http://www.barrhibb.com/documents/downloads/Barrie_Hibbert_Stochastic_Modelling__in_Wealth__Management.pdf

The model should assign probabilities to extreme events that reasonably reflect the risk of such events occurring in the ‘real world’. When used to support medium to long-term financial planning (i.e. for
investment terms of 5 years or more) the outcomes from a stochastic projection tool, and the decisions arising from the use of such a tool, should not be significantly impacted by short-term market ‘events’
such as those observed in 2008.

One More cannoincal Example:
=======================
Here's one of the canonical examples. Say you want to measure the area of a shape with a complicated, irregular outline. The Monte Carlo approach is to draw a square around the shape and measure the square. Now you throw darts into the square, as uniformly as possible. The fraction of darts falling on the shape gives the ratio of the area of the shape to the area of the square. Now, in fact, you can cast almost any integral problem, or any averaging problem, into this form. So you need a good way to tell if you're inside the outline, and you need a good way to figure out how many darts you should throw. Last but not least, you need a good way to throw darts uniformly, i.e., a good random number generator.

In Monte Carlo simulation, uncertain inputs in a model are represented using ranges of possible values known as probability distributions:
Normal – Or “bell curve.” Values in the middle near the mean are most likely to occur. It is symmetric and describes many natural phenomena such as people’s heights.
Lognormal – Values are positively skewed, not symmetric like a normal distribution. It is used to represent values that don’t go below zero but have unlimited positive potential. Examples of variables described by lognormal distributions include real estate property values, stock prices, and oil reserves
Uniform – All values have an equal chance of occurring, and the user simply defines the minimum and maximum. Examples of variables that could be uniformly distributed include manufacturing costs or future sales revenues for a new product.
Triangular – The user defines the minimum, most likely, and maximum values. Values around the most likely are more likely to occur. Variables that could be described by a triangular distribution include past sales history per unit of time and inventory levels.
PERT- The user defines the minimum, most likely, and maximum values, just like the triangular distribution. Values around the most likely are more likely to occur. It can generally be considered as superior to the Triangular distribution when the parameters result in a skewed distribution. An example of the use of a PERT distribution is to describe the duration of a task in a project management model.
Discrete – The user defines specific values that may occur and the likelihood of each. An example might be the results of a lawsuit: 20% chance of positive verdict, 30% change of negative verdict, 40% chance of settlement, and 10% chance of mistrial.

During a Monte Carlo simulation, values are sampled at random from the input probability distributions. Each set of samples is called an iteration, and the resulting outcome from that sample is recorded. Monte Carlo simulation does this hundreds or thousands of times, and the result is a probability distribution of possible outcomes. In this way, Monte Carlo simulation provides a much more comprehensive view of what may happen. It tells you not only what could happen, but how likely it is to happen.

Monte Carlo simulation provides a number of advantages over deterministic analysis:
Probabilistic Results. Results show not only what could happen, but how likely each outcome is.
Graphical Results. Because of the data a Monte Carlo simulation generates, it’s easy to create graphs of different outcomes and their chances of occurrence. This is important for communicating findings to other stakeholders.
Sensitivity Analysis. With just a few cases, deterministic analysis makes it difficult to see which variables impact the outcome the most. In Monte Carlo simulation, it’s easy to see which inputs had the biggest effect on bottom-line results.
Scenario Analysis. In deterministic models, it’s very difficult to model different combinations of values for different inputs to see the effects of truly different scenarios. Using Monte Carlo simulation, analysts can see exactly which inputs had which values together when certain outcomes occurred. This is invaluable for pursuing further analysis.
Correlation of Inputs. In Monte Carlo simulation, it’s possible to model interdependent relationships between input variables. It’s important for accuracy to represent how, in reality, when some factors goes up, others go up or down accordingly.












     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.