## Code Bug Fix: Expected payoff of the stock price using Montecarlo Simulation

Assume that stock currently sells for \$80 and follow a geometric Brownian motion and there is an option to purchase the stock price for \$40 in 6 months. Then, you can exercise (buy) the option if the price of the stock is greater than \$40; but if the stock sells for less than \$40, you would not exercise the option and your payoff is nil. So I need to find the expected payoff E(max(P-K,0)).

#Simulation of Geometric Brownian Motion
simGBM<- function(P0, mu, sigma, T, nt, ntray){
dt<-T/nt
muT<- (mu-sigma^2/2)*dt
sigmaT<- sqrt(dt)*sigma
Matrix_norm<- matrix(rnorm(nt*ntray, muT, sigmaT), nrow = ntray)
Increments_log<- cbind(log(P0), Matrix_norm)
Tray_log<- t(apply(Increments_log,1,cumsum))
return(exp(Tray_log))
}

P0<- 80 # Initial price of the stock
K<- 40 # Strike or exercise price
mu<- 0.1 # Drift
sigma<- 0.5 # Volatility
T<- 180/365 # Time measure in years
nt<- 1000 # Number of time steps
ntray<- 1100 # Number of replications or sample paths

paths<- simGBM(P0, mu, sigma, T, nt, ntray)

x<- as.data.frame(paths)
lastrow.x<- (slice(x, (nt+1))) - 40
exp.value<- apply(lastrow.x, 2, function(x) ({ifelse(x<0,0,x)}))

mean(exp.value)

Every time I run the code above it generates random numbers totally different for the stock price (i.e from \$10 to \$70). How I could obtain the expected value of the gain about \$40 without large variations?

Tagged : / /

## Server Bug Fix: How to build a quantum computer in your house?

As still quarantine is going on for some of us. I was wondering how to make a Quantum Computer in your garage. What may be the total cost for building one?

Was inspired by this youtube video.

A serious answer: you pretty much can’t. It’s not that you in particular can’t, it’s that no one can. Huge companies pour in huge amounts of money to try and make a proof-of-concept quantum computer (there is actually no ‘proper’ quantum computer yet).

A slightly less serious answer: some odd $$10-100$$ Million would get you started I would say. It all depends on what type of quantum bits you want to build; most of time require the need of cooling them down to single digits (or much, much less) above absolute zero. You need ‘special’ refrigerators for that will do this, and they are pricey.

Oh, and do you have a nanofabrication lab or a clean room adjecent to your garage? Because you’re probably gonna need one of those as well:)

This is not intended to shoot you down, but more as a light joke:)

Edit:
Actually, what might be in reach for a personal investment is some very rudimentary version of a photonic quantum computer. Basically you need some glass fiber, a couple of beam splitters, a lot of attenuators and some lasers. (And a idiotically expensive single-photon detector, but we’ll sweep that under the rug for now).

With current technology, there’s not much of a chance to build a true quantum computer, but you may be able to build some interesting quantum circuits with a fairly sizable (but still on the scale of “self-funded” for the ordinary person) budget, using the optical photon model. For instance, one could use the linear optical quantum computing model. Using beamsplitters as $$hat{y}$$ rotations and phase shifters as $$hat{z}$$ rotations, one can construct arbitrary one-qubit quantum gates. With the addition of a nonlinear medium (like Kerr Media), one can construct some interesting circuits. For reference, here are the transformations that each of those optical tools performs:
$$mathrm{B}_theta = begin{bmatrix} text{cos}(theta) & -text{sin}(theta) \ text{sin}(theta) & text{cos}(theta) end{bmatrix}$$
$$mathrm{P}_phi = begin{bmatrix} e^{i phi} & 0 \ 0 & 1 end{bmatrix}$$
$$mathrm{K}_mathcal{E} = begin{bmatrix} 1 & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & 1 & 0 \ 0 & 0 & 0 & e^{i mathcal{E}} end{bmatrix}$$
The parametrizations on the first two matrices have to do with the properties of the materials used in creating the optical tools, and don’t necessarily have anything to do with the physical angle which they are placed.

Note that while you probably can’t build a quantum computer at home, you can simulate one with a classical computer, at the cost of merely an exponential slowdown. There’s a rather long list of available software at https://www.quantiki.org/wiki/list-qc-simulators.

It’s actually an interesting question. And the previous answers (“strictly speaking, you can’t,” “you can simulate quantum computers,” and “photonics-based processing holds some promise”) are all true.

According to a pioneer in photonics computing we won’t see real quantum computing until around 2035. I’ve not yet seen anything to justify thinking to the contrary. Some of the downstream work of these photonic computing pioneers has yielded the fastest data interconnects that scale perfectly in parallel b/c there’s no photon-electron conversion (and because there’s an ingenious breakthrough at the core). There’s also a really compelling set of demonstrations using these interconnects to run QC simulations , like running Grover’s algorithm and QFT, fast. See https://www.datavortex.com/research/quantum-simulation/.

There’s nothing wrong with simulating, there’s nothing wrong with waiting 15 years, and there’s nothing wrong with jumping in and trying to make it happen in one’s garage. All one needs is some advanced mathematical training, some electricity, some money, and a refusal to quit.

All previous answers are true. I would like to contribute with a serious question and a comment.

Would it make sense to build a quantum computer in your house?

They are and will be hard to maintain. In my opinion, having them in the cloud is and will be the best solution.

Beecause of economy of scale, the cost of a home-made quantum computer will be always greater than the cost of industrial quantum devices deployed in server farms located in cold countries (e.g., Norway) and exposed as cloud services.

He has basically described how to build the Cirac-Zoller quantum computer.

In the most simple approach the qubit states are electronic states of the trapped ions. Two qubit gates are possible thanks to the coupling of the qubit states to the vibrational modes of the trap — this is cool as in superconducting architectures the two qubits that are far apart on the chip are not coupled directly.

The trapping of ions was already demonstrated a while ago e.g. here or here. As he has mentioned the next big step in his design will be placing the trap inside an ultra high vacuum (UHV) chamber i.e. less than 100nPa. This is necessary as otherwise the atoms from the air would bump into the ions and would cause decoherence.

But the really challenging step is implementation of the lasers as they do the whole job — this might be really difficult to achieve at home, however, judging on his current progress, I hope that he will pull it off.

A real competition to his start-up is a company called ionQ that is building quantum processors with a use of this architecture. The ion trap based quantum computers are known for having qubits and gates of v high fidelity. The drawback is that they are difficult to scale up. This is the most commonly attributed to anomalous heating.

Here you can check out other architectures with their strengths and weaknesses.

## Server Bug Fix: Monte-Carlo Simulations in inventory management

I am using Monte-Carlo simulations in Microsoft Excel to determine optimum reorder points and safety stock levels. I have the demand patterns of the last one year of the product. Using that I can construct a cumulative distribution function of the demand to draw random samples from and construct a table of demand on each day for a whole year.

One problem that I found was that the simulation is based on demand patterns alone. That is, if the company did not forecast at all, then the individual runs of the simulation would generate the demand pattern that they can expect in a year. However, if the company is able to forecast demand with 100% accuracy, then there would be no need to keep a safety stock (or very little of it). Forecast accuracy is something I am not sure how to incorporate in my model. There are formulas for calculating safety stock such as using the Mean Absolute Deviation from the forecasted demand but I would like to develop a simulation model that takes into account forecast accuracy. Thanks in advance.

I’m in general agreement with Larry’s answer, but with one qualification. If you are generating random demand quantities from the sample CDF for a year, your demands will not conform to any trends or seasonal patterns (or even just short-term autocorrelation) in the historical data. If you then generate forecasts from the randomly sampled observations, the forecasts will also not contain trend or seasonality (and perhaps not autocorrelation, or the wrong autocorrelations), so you will be missing a chance for greater accuracy. If you use rolling forecasts from the historical data, then there will be a mismatch between forecasts and “actual” (meaning sampled) demand.

One way to mitigate this is to first analyze the historical data and see if you can suss out any patterns. Use them to build a model for the demand process. In the simulation, obtain demand observations from this model (using it to predict the current observation, then adding a bit of noise). Simultaneously use forecasts obtained from the simulated data (possibly using the same model, possibly using something similar such as exponential smoothing, perhaps with a seasonal component).

Why not build the forecasting directly into your simulation? So, in each period $$t$$, you generate a forecast $$y_t$$ using whatever method you want (moving average, exponential smoothing, etc.), and choose an order quantity based on the forecast and the current estimate of the standard deviation of the forecast error. Then generate the random demand, calculate the forecast error, and update the estimates of the SD of the FE.

Tagged : /

## Math Genius: compute cumulative average

I have below table which i compute the average in the end of the month.

M1  |M2  |M3    |Total(M1+M2+M3) |Average(M1+M2+M3)/3  |
----|----|------|----------------|---------------------|
100 |300 |200   |600             |200                  |

How can i simulate this table to come to the same average as shown above, when column M3 is redistributed within the month. M1 and M2 remain constant since they are result of previous month

M1  |M2  |M3    |Total(M1+M2+M3) |Average(M1+M2+M3)/3  |
----|----|------|----------------|---------------------|
100 |300 |35    |xx              |xx                   |
100 |300 |60    |xx              |xx                   |
100 |300 |0     |xx              |xx                   |
100 |300 |70    |xx              |xx                   |
100 |300 |10    |xx              |xx                   |
100 |300 |25    |xx              |xx                   |
-------------------------------------------------------
TOTAL    |200   |600             |200                  |

This is because i don’t want to wait until the end of the month to know the results , but would like to know the preliminary accumulating results

Tagged : / /

## Server Bug Fix: Pass The ⚽️ Around The Circle

The ball game is a game in which a number of players sit together in a circle. Each player is first assigned a number $$n$$, either 1, 2, or 3. The game begins with any starting player, and proceeds clockwise around the circle. The current player with the ball throws it to the next player. Who the next player is solely depends on the number $$n$$ the current player was assigned.

If $$n = 1$$, the next player will be the one sat directly adjacent (one space away), traveling in the current direction.

If $$n = 2$$, the next player will be the one sat two spaces away, traveling in the current direction.

If $$n = 3$$, the direction of play is first switched (clockwise to counter-clockwise, and vice-versa). The next player will then be the one sat directly adjacent, traveling in the new direction.

You are given a list of numbers $$l$$ all in the range $$[1 – 3]$$, denoting the numbers each player was assigned. The elements in $$l$$ are given in clockwise order, and such that the last element of $$l$$ is adjacent to the first element. Your task is to determine the number of players who have touched the ball, before it reaches a player who previously already touched the ball.

### Example

The starting player is at the first index. X represents a visited index, O represents an index visited twice.

[1, 2, 1, 1, 2, 2, 3] ->
[X, 2, 1, 1, 2, 2, 3] ->
[X, X, 1, 1, 2, 2, 3] ->
[X, X, 1, X, 2, 2, 3] ->
[X, X, 1, X, X, 2, 3] ->
[X, X, 1, X, X, 2, X] ->
[X, X, 1, X, X, X, X] ->
[X, X, 1, O, X, X, X]
The answer is 6.

## Clarifications

• $$l$$ can be inputted in any reasonable format, but the numbers 1, 2, and 3 must not change
• The starting player does not have to be at the first index, but please specify where it would start
• This is , so the shortest code in bytes wins!

## Test Cases

Input (start is index 0) -> Output
[1] -> 1
[2] -> 1
[3] -> 1
[3, 2] -> 2
[2, 1] -> 1
[2, 2, 3] -> 3
[1, 1, 1, 1, 1] -> 5
[2, 2, 2, 2, 2] -> 5
[3, 3, 3, 3, 3] -> 2
[1, 3, 2, 1, 2, 3] -> 2
[1, 2, 1, 1, 2, 2, 3] -> 6

# Python 3, 67 55 bytes

f=lambda x,*l:x and-~f(*l[x%3-1::1-x//3*2],0,*l[x%2:1])

Try it online!

Use @Leo’s idea of keeping the current player at a fixed index and transforming the list instead. Be sure to check out and upvote his answer!

If the current list is [x, a, b, c, d], where x is the move of the current player, then we want to rotate the list appropriately, and replace x with 0:

• If x == 1, the new list is [a, b, c, d, 0]
• If x == 2, the new list is [b, c, d, 0, a]
• If x == 3, the new list is [d, c, b, a, 0]
• If x == 0, this player has already been visited, thus we stop the algorithm.

# Python 2, 90 85 bytes

f=lambda l,d=1,p=0,*t:(p in t)^1and-~f(l,[d,-d][l[p]>2],(-~l[p]%4*d-d+p)%len(l),p,*t)

Try it online!

Not every elegant, but does the job.

This recursive function keeps track of the current direction d, the position p, and the list of seen position t.

# Husk, 16 bytes

←LU¡Γ!Moëṙ1ṙ2↔IΘ

Try it online!

Takes a list of numbers where the ball is currently at the first element and keeps rotating/reflecting the list to keep the ball in the first position while setting any visited element to 0. Returns how many different lists were created this way (-1).

For a more detailed explanation of the code (hard to do, but I’ll try):

←LU¡Γ!Moëṙ1ṙ2↔IΘ
ëṙ1ṙ2↔I  List of four functions [rotate by 1, rotate by 2, reflect, do nothing]
Mo       Θ Make each of these functions prepend a 0 to the list before doing anything

Γ!           Use the first element of the input list as an index into the list
of functions, and apply that function to the rest of the input list.
Note that indexing with a 0 returns the last function (do nothing)

¡             Iterate this process and keep all the results produced
U              Discard all results after the first repeated one
←L               Return the number of results minus one

I’m a bit sad for all the bytes I’m taking to do ←LU, but I couldn’t find a shorter alternative (damn 1-based indexing!)

# C (gcc), 94 92 bytes

c;s;i;d;p;f(l,n)int*l,n;{p=1;for(s=i=0;c=l[i];++s,l[i]=0,i=(i+p*d+n)%n)d=c>2?p*=-1,1:c;p=s;}

Try it online!

Inputs an array of int along with its length and returns the number of players touched before a repetitive touch.

How?

Passes the ball around setting the last place the ball was to $$0$$ and incrementing the counter $$s$$. When we arrive back at a $$0$$ we’re done and return $$s$$.

Commented code

c;s;i;d;p;f(l,n)int*l,n;{
p=1;                /* polarity is initialised to 1 forwards.
-1 is backwards */
for(s=i=0;          /* initialise counter and index */
c=l[i];         /* stop looping when we hit a zero
and cache the current value in c */
++s,            /* after loop bump our count */
l[i]=0,         /* and zero last player */
i=(i+p*d+n)%n)  /* and move index d places
in polarity p direction
adding n so we never go negative
when we make it all mod n */
d=c>2?p*=-1,1:c; /* if number is 3 reverse polarity p
and set d to 1 otherwise set d to
the number */
p=s;                /* return s */
}

# JavaScript (ES6), 67 bytes

a=>(d=1,g=x=>(n=a[x%=w=a.length])&&!(a[x]=0)+g(x+=n-3?n*d:d=w-d))``

Try it online!

### Commented

a => (                    // a[] = input array
d = 1,                  // d = direction
g = x =>                // g is a recursive function taking the current position x
( n =                 //   n is the player number at the current position
a[                  //
x %=              //   take the wrap-around into account by computing
w = a.length    //   x modulo w, where w is the length of a[]
]                   //
) &&                  //   stop the recursion if a[x] is equal to 0
!(a[x] = 0) +         //   otherwise, set it to 0 and increment the final result
g(                    //   do a recursive call:
x +=                //     update the position:
n - 3 ? n * d     //       add n * d to x if n is not equal to 3
: d = w - d //       otherwise, reverse the direction and add it to x
)                     //   end of recursive call
)``                       // initial call to g with a zero'ish value for x

# J, 39 bytes

1-~&#[:({.(|.*1*@+2*[)0,}.)^:a:]+_4*=&3

Try it online!

I solved this independently before looking at other answers, but have stumbled on the same high-level approach used by Leo and Surculose Sputum.

A few details appear to be different:

1. ]+_4*=&3 I start by transforming all 3s in the list into -1s, so that I don’t have to special case any code. J automatically treats a negative rotation as the reverse direction.
2. Instead of reversing the list when I hit a -1, I multiply all numbers on the list by -1. I avoid special casing here too by always multiplying all numbers on the list by the following quantity: “double current value, add 1, take sign num” 1*@+2*[. The quantity will be 1 for all values greater than 0, and -1 when the value is -1.

# R, 9787 85 bytes

function(p,i=1)sum(while(m<-p[i]){p[i]=0
i=(i+`if`(m>2,T<--T,m*T)-1)%%sum(p|1)+1},!p)

Try it online!

Edit: -10 bytes by tracking direction of travel (instead of flipping list of players)

Edit 2: re-arranged to cull 2 more characters

touches=function(p,         # p=player numbers
i=1)                    # i=current player
sum(
while(m<-p[i]){     # while m=number of current player is non-zero
p[i]=0          # set his number to zero
i=i+            # calculate new player:
`if`(m>2,       # if m is 3...
T<--T,      # flip the direction of travel T and move by this
m*T)        # otherwise move ahead by T*m
-1)%%sum(p|1)+1 # -1, modulo number of players, +1
}                   # (R indices are 1-based)
!p)                 # sum of null (the return value of 'while')
# and the final number of zeros

# 05AB1E, 22 21 bytes

Explanation:

[                # Loop indefintely:
ć               #  Extract head; pop and push remainder-list and first item separately
©              #  Store this first item in variable `®` (without popping)
_             #  Check if its 0
#            #   And if it is, stop the infinite loop
0š              #  Prepend a 0 at the start of the list
„RÀ           #  Push string "RÀ"
S          #  Convert it to a list of characters: ["R","À"]
#  (NOTE: The `ª` already implicitly converts it to a list of
#   characters, so this usually isn't necessary; but without it the
#  `„RÀ¤` would act like a dictionary string and become "R cry")
¤         #  Push its last item (without popping): "À"
º        #  Double it by mirroring: "ÀÀ"
ª       #  Append it to the list: ["R","À","ÀÀ"]
®è     #  Index `®` into this list (0-based and with wraparound,
#  so the 3 will index into the first item "R")
.V   #  Execute it as 05AB1E code
#   "R": Reverse the list
#   "À": Rotate the list once towards the left
#   "ÀÀ": Rotate the list twice towards the left
¼  #  Increase the counter_variable by 1
}¾               # After the infinite loop: push the counter_variable
# (after which it is output implicitly as result)

# Charcoal, 30 bytes

Ｗ⊟θ≔⁺⎇⁼ι²⟦⊟θ⁰⟧⟦⁰⟧⎇⁼ι³⮌θθθＩ⊕№θ⁰

Try it online! Link is to verbose version of code. Based on @Leo’s idea explained better by @SurculoseSputum. Takes input in reverse order. Explanation:

Ｗ⊟θ

Let the current list be [e, d, c, b, a]. Remove the last element a, which represents the current player. Then if it is non-zero, meaning that they have not played yet:

≔⁺⎇⁼ι²⟦⊟θ⁰⟧⟦⁰⟧⎇⁼ι³⮌θθθ

Create two lists depending on the value of a:

1. [0] and the rest of the list [e, d, c, b]
2. [b, 0] (obtained by popping b from the list) and the rest of the list [e, d, c]
3. [0] and the reverse of the rest of the list [b, c, d, e]

Concatenate them together to create the new state of the list.

Ｉ⊕№θ⁰

Print 1 more than the number of 0s in the list (because we popped a so that’s no longer in the list).

# perl -M5.010 -a, 84 bytes

\$:=1;{(\$;=\$F[\$,])?do{\$:=-\$:,\$;=1 if\$;==3;\$"++;\$F[\$,]=0;\$,=(\$,+\$;*\$:)%@F;redo}:say\$"}

Try it online!

This just follows the rule of the game, labelling any visited player as 0, and terminating when it encounters a player labelled 0. Steps are counted and printed at the end.

The code in the header section of TIO is just there to make it work on multiple inputs; leave it off for a single line of input.

# JavaScript (Node.js), 81 bytes

s=>s.map(_=>(t=s[r=p%q])?s[p+=t>2?w*=-1:t*w,r]=!++n:0,q=s.length,n=0,p=3*q,w=1)|n

Try it online!

# Perl 5-pa, 66 bytes

while(\$_=\$F[\$i]){\$F[\$i]=0;\$.*=-1if/3/;\$i+=\$.+\$.*/2/;\$i%[email protected];\$++}}{

Try it online!

# Ruby, 63 bytes

f=->a,d=1{x,*a=a;x ?1+f[[p,*a].rotate((2-x%2)*d*=1-x/3*2),d]:0}

Try it online!

Tagged : /

## Linux HowTo: Insane power dissipation on EL34 tubes in push-pull power stage

Here’s my circuit:
(now without voltages)

It uses two EL34s biased to -30V (fixed bias).
Here’s the loadline (made with this calculator):

When no signal is applied voltage on EL34 anodes is 360V, as expected, and current is around 40mA, as expected.
However when I apply 50V p-p signal (V8 and V9 are generating phase inverted signals), weird things start to happen:

Power dissipation on EL34 anodes is going up to 110W. Signals on EL34 grids are correct.

[AFTER EDIT, corrected inductances]
I’m running this simulation in Micro-Cap 12.
I suspect that something is wrong with transformer. Speaker transformer is Hammond 1650HA, and I’ve used component named ‘centap’ for transformer, and copied inducance values from 1650HA’s datasheet. (11.3H primary, which results in 2.825 to center tap, and 214.5mH for secondary 8 Ohm output).

(Inductance values are now corrected, thanks for pointing it out)

Loadline was generated with transformer primary impedance of 6.6k Ohm.
Datasheet says that primary impedance is 6.6k, and secondary has three outputs for 4,8 and 16.
There was nothing about impedance when I was defining transformer in micro-cap. Since only values that I could specify were inducances, I thought that setting proper inductances implies that all other values are also correct. However when I plot impedance of transformer, I see that these values have nothing to do with 6.6k (or 3.3k each)

The question is: is something wrong with my circuit, or it’s just issue with the software?
In case it’s issue with software, could anyone who has experience with micro-cap 12 tell me how to properly simulate Hammond 1650HA in this software?

EDIT: This circuit is using the same transformer, and is almost identical(in fact when I modified my circuit to be exactly identical I’m still getting wrong results). It’s author build it and it worked for him, his EL34s didn’t melt or explode, so I think my circuit is also correct, and therefore I think there are two possibilities:
1. I’ve implemented 1650HA incorrectly
2. I’ve measured power incorrectly.

EDIT 2:
Since impedance of transformer should be 3.3k for each side, I’ve replaced it with 3.3k resistors, and now I’m getting correct power measurements, power dissipated on EL34s is slightly below 20W, and average power on load is ~32W.

For one thing, you’ve modeled the transformer incorrectly. If the total primary inductance is 11.3 H, then the inductance of each half is 2.825 H — 1/4 of the total, not 1/2. Remember, all other things kept equal, inductance is proportional to N2 — the number of turns squared. Since each half of the winding has half the turns, it has 1/4 the inductance. The rule about inductances in series simply adding only applies when their fields are not coupled.

Fixing this will greatly increase the coupling to the load. Note that the power that you are currently measuring is almost purely reactive — the current peaks are aligned with the points where the voltage across the transformer is zero. The real power being coupled to the load is negligible in proportion.

Also, it appears that you’ve specified the secondary inductance as 214.5 H, not mH.

Now that you’ve fixed the issues mentioned above, I believe there are still problems with the values you’re using. Where did you come up with those inductance vallues? I can’t find any mention of inductance in any of the Hammond data.

In any case, I’m willing to believe that the primary inductance is on the order of several henries for this type and size of transformer. But the inductance ratio to the secondary should be equal to the impedance ratio (both are proportional to N2), which means that the secondary inductance in your model should be only

$$2.825text{ H} frac{8 Omega}{3300 Omega} = 6.85text{ mH}$$

The high (measured) values for secondary inductance listed in the datasheet are the result of second-order effects such as leakage inductance (imperfect coupling), which appears in series with the secondary terminals.

Tagged : / / /

## Math Genius: Outage Probability: Simulation VS Analytical results

I want to find the outage of a node in decode-and-forward (DF) relay.

Mathematically, I want to find

\$eqalign{Pr(min(SNR_R, SNR_D)<SNR_{thr})}. tag{1}\$

which in probabilistic terms is equal to
\$eqalign{Prleft(min(X,Y)le xright) &= F_X(x) + F_Y(x) – F_X(x)F_Y(x) \&= 1 – (1-F_X(x))(1-F_Y(x)).tag{2}}\$

I have derived the analytical expressions for both \$F_X(x)\$ and \$F_Y(x)\$, and both of them separately matches with the simulation results. Which means if I plot the \$Pr(SNR_R<SNR_{thr})\$ it matches the CDF \$F_X(x)\$ and similarly if I plot the \$Pr(SNR_D<SNR_{thr})\$ it matches the CDF \$F_Y(x)\$. However, when I try to plot Eq. \$(1)\$ and \$(2)\$ together, they don’t match.

Any help in this regard will be very much appreciated.

UPDATE: When I calculate the outage separately and plot them using eq.2, it matches. e.g. let’s assume

\$eqalign{poutR=SNR_R<SNR_{thr}}\$

\$eqalign{poutD=SNR_D<SNR_{thr}}\$

and then plot

\$eqalign{pout=poutR + poutD – poutR*poutD} \$

it exactly matches the analytical results derived using

\$eqalign{Pr(min(X,Y)< x) = F_X(x) + F_Y(x) – F_X(x)F_Y(x)}\$.

My question is: Is it correct to plot the simulation results like this? and what is the reason behind this?

Any help in this regard will be very much appreciated.

Without knowing the particulars, it is difficult to diagnose your difficulty.
Below is a simple example of what I guess you are doing, for which I get satisfactory
results. If this is not what you had in mind, maybe you can use it as a basis
to clarify your question.

If \$X_1 sim mathsf{Exp}(rate=lambda_1)\$ and independently
\$X_2 sim mathsf{Exp}(lambda_2),\$ then
\$V = min(X_1,X_2) sim mathsf{Exp}(lambda_1 + lambda_2).\$
This is easily proved using CDFs.

To simulate for rates 1/2 and 1 in R statistical software, one might use
the following code.

set.seed(1212); m = 10^6
x1 = rexp(m, 1/2);  x2 = rexp(m, 1)
v = pmin(x1, x2)
mean(x1);  mean(x2);  mean(v)
## 2.00038     # aprx E(X1) = 2
## 0.9993378   # aprx E(X2) = 1
## 0.6658064   # aprs E(V) = 1/(1.5) = 2/3

Comparing the ECDF of the first 5000 simulated realizations of \$V\$ with the theoretical CDF \$F_V,\$
I get the figure below. Within the resolution of the plot, the match seems
perfect:

V = v[1:5000]
plot.ecdf(V, main="ECDF of Simulated V [black] with CDF of EXP(1.5) [dashed red]")
curve(pexp(x, 1.5), col="red", lwd=3, lty="dashed", add=T)

## Steam Game: DCS: Flaming Cliffs 3

DCS: Flaming Cliffs 3 is the next evolution of the Flaming Cliffs series that operates with DCS World. FC3 features the F-15C, A-10A, Su-27, Su-33, MiG-29A, MiG-29S and Su-25. The FC3 aircraft provide an easy learning curve for new players and focuses on a broad range of aircraft rather than a detailed single aircraft. FC3 adds a number of new features and improvements to previous versions of the Flaming Cliffs series. FC3 is a module of DCS World, which makes it compatible with all other DCS World titles like A-10C, Black Shark 2, P-51D, Combined Arms, UH-1H Huey and Mi-8MTV2 Magnificent Eight.

## New Key Features for the Flaming Cliffs Series

• A DCS World module that is compatible with DCS titles.
• Professional Flight Models (PFM) for the F-15C, Su-27, A-10A and Su-25. New PFM coming for the Su-33 and MiG-29!
• New 6 degrees of freedom (6DOF) cockpits for all aircraft.
• New and improved external models for all aircraft.
• New campaigns and single missions.
• Improved flight dynamics and sensors for air-to-air missiles.
• Updated and improved HUDs and other cockpit systems.
• Resource Manager that adds logistics control to missions.
• Expanded theatre of operations map into eastern Georgia.
• Countless other improvements in the areas of the mission editor, special effects, new models, improved terrain detail and AI.

## F-15C Eagle

The F-15C has often been labeled as the greatest fighter aircraft in the world. Designed to counter the exaggerated capabilities of the Soviet MiG-25 “Foxbat”, the F-15C has been the backbone of U.S. air defense for three decades. The F-15C, equipped with improved avionics and weapons over the original F-15A, has scored over 100 air-to-air victories in the service of Israel, Saudi Arabia, and the U.S. without suffering any losses.

The F-15C rules the Beyond Visual Range arena (BVR). No slouch in a dogfight, the F-15C excels at finding targets, positively identifying them as hostile, and engaging them with AIM-120C AMRAAM missiles before the enemy can respond.

The F-15’s versatile pulse-Doppler radar system can look up at high-flying targets and down at low-flying targets without being confused by ground clutter. It can detect and track aircraft and small high-speed targets at distances beyond visual range down to close range, and at altitudes down to tree-top level. The radar feeds target information into the central computer for effective weapons delivery. For close-in dogfights, the radar automatically acquires enemy aircraft, and this information is projected on the head-up display.

## A-10A Thunderbolt II

Designed as a Close Air Support (CAS) platform to counter the massive quantities of Soviet armor during the Cold War, the “Hog” is heavily armored and carries an impressive weapons load including the deadly GAU-8A 30mm anti-armor cannon. Efforts to retire the A-10 from active duty began gaining momentum in the late 1980s, but fell by the wayside after the aircraft’s stellar performance during the 1991 Gulf War.

The A-10 was intended to fly low, using the terrain to mask its presence from enemy SAMs. Low flying, however, places the aircraft in the heart of the AAA engagement zone. Therefore, the aircraft is heavily armored, including a “titanium bathtub” that surrounds the pilot. When the threat of SAMs has been reduced, the A-10 generally flies missions at medium altitudes, placing it safely out of the reach of AAA guns.

The sub-sonic A-10 can carry AIM-9 Sidewinders for self defense, but should avoid dogfighting. It carries an impressive air-to-ground weapons load, but lacks the power for a sustained fight against a dedicated air-to-air platform. When confronted by an enemy fighter, the Hog pilot should use the A-10’s impressive turn rate capability to point the nose (and the dreaded 30mm cannon) at the attacker. When the attacker overshoots, unload and extend until the attacker makes another pass, then use another maximum-rate turn to point the nose back at the adversary.

## Su-27 and Su-33 Flanker

The Su-27 Flanker B and its variants are some of the most impressive and capable fighter aircraft in the world, designed to beat the vaunted F-15C. Born in the waning years of the Cold War, the Flanker did not have an easy life. The initial design suffered serious problems. Then, the breakup of the Soviet Union hindered its deployment, denying it the opportunity to prove itself as one of the world’s greatest aircraft.

The Su-27 is tailored for air-to-air combat, not air-to-ground. Armed with the R-27 (AA-10) Alamo series of missiles, the Flanker has an impressive beyond visual range (BVR) capability. Meanwhile, the helmet mounted sight and high off-boresight R-73 (AA-11) Archer heat-seeking missile, coupled with the Su-27’s high thrust and sustained turn capability, gives the aircraft a powerful edge in a knife fight. High-AoA maneuvering helps the pilot point his weapons at the enemy. Finally, its very large internal fuel capacity keeps it in the fight well after other fighters are running on fumes. It carries as many as ten air-to-air missiles, giving it an impressive “punch”.
Detractors criticize the Su-27’s avionics and cockpit layout, citing limited ability to track/engage multiple targets, high reliance on Ground Control Intercept (GCI) control, and high pilot workload. However, its passive Electro-Optical System (EOS) lets it find and engage targets without any radar emissions (which can warn the target). Debate continues whether high-AOA maneuvers (such as tail slides and the famed “Cobra”) are useful as combat tactics or merely impressive air show stunts.
Su-27 pilots should keep in mind that although the Flanker has a very large internal fuel capacity, hence the lack of external fuel tanks, a fully fueled Flanker can be a very poor performer in a dogfight.

Originally named the Su-27K, this cousin of the Su-27 was specifically designed to operate from Soviet aircraft carriers. Equipped with canards for improved take off and landing performance, the first Su-27K made its maiden flight in 1985. The tail cone was shortened to reduce the risk of tail strike during high-AoA carrier landings, but this also reduced the space available for defensive countermeasures (including chaff and flare dispensers). The Su-33 uses the same radar as the Su-27 and, to a large extent, the same cockpit as well. Neither the Su-33 nor Su-27 has air-to-surface radar modes.

## Su-25 Frogfoot

The Su-25 Frogfoot bears little resemblance to the U.S. A-10A, but it was designed for a very similar Close Air Support (CAS) ground-attack mission. The Su-25 was built to operate near the forward edge of battle area (FEBA) from rough, “unimproved” airstrips, and can carry a loadout with tools, spare parts, auxiliary power supply, a pump for manual refueling and other “self deployment” supplies. It carries a wide variety of weapons for missions including anti-personnel, runway denial, and tank killing.

The fortified cockpit and armored canopy help protect the pilot from anti-aircraft artillery (AAA) and small arms fire while engaging targets at low altitude. Ingressing at low level, the Su-25 hunts down targets, pops up, delivers its weapons, and dives back behind terrain. The Su-25 may arguably be the most power ground-attack aircraft in Eastern inventories.

The Su-25 is not intended for dogfighting though. Its primary defense against patrolling fighters is simple avoidance. When engaged, the Su-25 should operate at extremely low altitude, which hampers enemy fighters’ ability to engage it. Using terrain as available, the pilot should turn to face oncoming threats or extend away from the fight if given the opportunity.

## MiG-29A and MiG-29S Fulcrum

Western observers often conclude, inaccurately, that the Su-27 and MiG-29 were born of a single design program, which copied the U.S. Navy’s F/A-18, no less. Indeed, the Su-27 and MiG-29 look quite similar and some observers cannot readily tell the two aircraft apart, despite the MiG-29 being substantially smaller than the Su-27. Both the Su-27 and MiG-29 design teams reportedly worked with common research data and drew common design conclusions. The MiG-29 has been much more widely exported than the Su-27, serving in many former Warsaw Pact air forces, several of which have since joined NATO (bringing their Soviet-made MiG-29s with them).
The MiG-29 originally shared most of its avionics suite with the Su-27 (including the radar, the Electro-Optical System (EOS), and the helmet-mounted sight), but was designed as a short-ranged fighter, not as an interceptor. The EOS lets the Fulcrum search for, track, and engage targets without emitting telltale radar signals. Being smaller, it doesn’t carry as many missiles as the Su-27, but its high-AoA maneuverability coupled with the R-73 (AA-11) Archer high off-boresight, heat-seeking missile and helmet mounted sight makes the MiG-29 a deadly dogfighter. The slow-speed turning fight is the MiG-29’s preferred arena where it can use its high-AoA capability to point its weapons at a floundering target. The newer MiG-29S includes onboard electronic countermeasures, a greater fuel load, and the ability to carry the medium-ranged R-77 (AA-12) Adder missile.

As with the Su-27, critics cite weak avionics and poor cockpit design as weaknesses of the MiG-29. The later MiG-29S (Fulcrum C), though, incorporated numerous improvements including better defensive countermeasures and increased fuel capacity. The MiG-29 reportedly requires a significant amount of maintenance, especially the engines. German MiG-29s (inherited from the East when Germany was re-unified) have had their engine performance “tuned down” to somewhat lengthen engine lifespan. Obtaining spare parts continues to be a concern for former Warsaw Pact nations.

Russian forces in DCS World employ the MiG-29A and MiG-29S, while German forces operate only the MiG-29A.

Tagged : / / /

## Steam Game: DCS: A-10C Warthog

DCS: A-10C Warthog is a PC simulation of the U.S. premier Close Air Support attack aircraft. This is the second aircraft in the DCS series, following DCS: Black Shark, and raises the bar even higher in the DCS series. Warthog brings the most realistic PC simulation of a modern fixed wing combat aircraft in regards to flight dynamics, avionics, sensors, and weapon systems. You also have the option to play Warthog in “Game” mode for a casual game experience. Fly missions in the Caucuses region of the Black Sea against and with a wide array of air, land and sea forces with new and improved intelligence. Create your own missions and campaigns with the included Mission and Campaign Editors, and fly with and against friends online using the included online game browser.

## Key features:

• Fly the A-10C “Warthog” in either realistic or game modes.
• Fly missions in either Georgia and Russia.
• Interactive training missions shallow the learning curve dramatically.
• Rich campaigns and single missions included.
• Feature-rich Mission and Campaign editors allow user created content.
• The most realistic flight dynamics ever done for a PC simulation.
• Huge array of land, air and sea units to flight along and against.
• Ability to command ground forces during missions.
• Fully interactive Forward Air Controller (FAC) that helps you find targets.
Tagged : / / / /

## Steam Game: DCS: AV-8B Night Attack V/STOL

The AV-8B project was born in the early 1970’s as an effort to address the operational inadequacies of the AV-8A first generation Harrier, aimed to dramatically improve the capabilities and performance of the early AV-8A’s. The AV-8B made its maiden flight in November 1981 and entered service with the United States Marine Corps in January 1985. It later evolved into the AV-8B N/A (Night Attack) and AV-8B Harrier II Plus.

First flight of a modified AV-8B in the night attack configuration was on June 26th, 1987. Deliveries to the USMC began in September of 1989 to VMA-214 at Yuma, Arizona. Follow-up units based out of Yuma received their Night Attack AV-8Bs by the end of 1992.The AV-8B N/A variant (originally known as the AV-8D) had its first operational development in 1984 and included use of the NAVFLIR (Navigation Forward-Looking Infrared camera, consisting of a GEC-Marconi FLIR system mounted in the nose) for night operations. Additionally, GEC Cat’s Eyes night vision goggles were provided to the pilot as well as a revised cockpit with color MFDs, a wider field-of-view HUD display, a color CRT digital moving map, and a complete “heads-down” operation capability. The AV-8B N/A also sports four Tracor ALE-39 countermeasures dispensers along the top of the rear fuselage, in addition to two ALE-39 dispensers along the lower rear of the fuselage. The AV-8B N/A also fields an updated version of the Rolls-Royce Pegasus 11-61 (F402-RR-408) vectored-thrust turbofan engine.

The subject of this study level simulation is the AV-8B N/A Bu No’s 163853 and up which are the latest variant of this very capable AV-8B version.

## Key Features of DCS: AV-8B N/A VTOL by RAZBAM include:

• Advanced Flight Model that provides realistic performance and flight characteristics of a Vertical Takeoff and Landing (VTOL) aircraft
• Highly detailed external 3D model and textures with animations
• Highly detailed and accurate 6 DOF cockpit with high resolution textures, specular and bump mapping, and mouse-interactive controls
• Highly realistic modelling of the aircraft systems including electrical, fuel, hydraulics, lighting, engine and navigation that includes:
• Digital Engine Control System (DECS)
• Automatic Fuel System
• Air Refueling System
• Electrical Power System
• External Lighting
• Internal Lighting
• Hydraulic Power Supply System
• Flight Control System (FCS)
• Head-Up Display (HUD)
• Up-front Control (UFC)
• Option Display Unit (ODU)
• Multipurpose Color Displays (MPCD)
• VREST Computer (for jet-borne flight)
• Air Data Computer (ADC)
• Environmental Control System (ECS)
• On-Board Oxygen Generating System (OBOGS)
• Realistic weapons, sensor, and defensive systems include:
• Air-to-Air and Air-to-Ground GAU-12 Equalizer 25 mm (0.984 in) 5-barreled Rotary cannon pod
• 6 under-wing pylon stations holding up to 9,200 lb (4,200 kg) of payload which include:
• AIM-9 Sidewinder or similar-sized infrared-guided missiles
• AGM-65 Maverick Air-to-Surface missiles
• Mark 80 series of unguided bombs (including 3 kg [6.6 lb] and 14 kg [31 lb] practice bombs)
• Paveway series of Laser-Guided Bombs (LGBs)
• Joint Direct Attack Munitions (GBU-38, GBU-32, and GBU-54)
• Mark 20 Cluster Bomb Units (CBUs)
• AN/AAQ-28V LITENING targeting pod
• ALQ-164 ECM Pod
• Several skins
• Detailed Operational Manual and Pocket guide
• Instant Action, Single, and Training Missions
• Detailed representation of the USS Tarawa (LHA-1), lead ship of her class.

## Further additions coming:

• Moving map
• GPS-guided weapons
• Fully functional inertial navigation system
• Additional targeting pod features
• Auto pilot modes
Tagged : /