1

I want to simulate price with the following code:

import numpy as np
import matplotlib.pyplot as plt

final_price = []

for i in range(1000): amp = 0.01 length = 10000 diff = np.random.uniform(-0.01, 0.01, length) price = np.cumprod(1 + diff) final_price.append(price[-1])

plt.hist(final_price, bins=100) plt.show()

the final price has the following distribution:

enter image description here


I found the following from this paper for question 2.

enter image description here

update

I ran the simulation with the following code and the result is very surprising: at each step, the change is uniformly distributed between -1% and 1%, but at the end, 810 / 1000 ends up smaller than 1, and 190 bigger than 1. This is very counter-intuitive

import matplotlib.pyplot as plt
import numpy as np

Y = [] for i in range(1000): X = np.random.uniform(0.99, 1.01, 100000) Y.append(np.prod(X)) Y = np.array(Y) bigger = sum(Y > 1) smaller = sum(Y < 1) plt.title(f"bigger than 1: {bigger}, smaller than 1: {smaller}") plt.hist(Y, 100) plt.show()

enter image description here

em1971
  • 306
  • 2
    Please add the [tag:self-study] tag & read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. Please make these changes as just posting your homework & hoping someone will do it for you is grounds for closing. – kjetil b halvorsen Mar 11 '24 at 16:23
  • @kjetilbhalvorsen This is not a homework question. I googled and asked ChatGPT, but couldn't find answers, this is all I got so far. – em1971 Mar 11 '24 at 16:27
  • https://stats.stackexchange.com/questions/3707 is a closely related question. – whuber Mar 11 '24 at 17:43
  • Re "surprising:" Consider the simplest possible non-trivial instance of this phenomenon where the price changes independently twice, increasing or decreasing 50% with equal chances each time. The four possible outcomes, each with chance $1/4,$ are relative prices of $(1-0.5)^2=0.25,$ $(1-0.5)(1.5)=0.75,$ $(1+0.5)(1-0.5)=0.75,$ and $(1+0.5)(1+0.5)=2.25.$ Please contemplate (a) what the expected outcome is and (b) what proportion of outcomes are net decreases from the original price. – whuber Mar 11 '24 at 20:39
  • There’s a difference between taking the same random variable and raising it to a power and taking many random variables (even if they are identically distributed) and multiplying them @em1971 – Taylor Mar 11 '24 at 23:50
  • @whuber so can I say "in a completely random market, a person is more likely to end up losing money". Also, since most prices do not end up less than their initial value, can I say "the market is not random, thus we can find patterns and exploit them. (FYI, i know the expectation is 1. I am saying "there is 3/4 chance you lose, and 1/4 chance you win") – em1971 Mar 12 '24 at 07:40
  • why a question like "Dot product vs Element-wise multiplication" gets 15 votes (https://stats.stackexchange.com/questions/533577/dot-product-vs-element-wise-multiplication), where as mine gets closed?????? can't this person use Google to find definitions for his self-study? this is ridiculous – em1971 Mar 12 '24 at 07:43
  • Because I did not vote to close this thread, I can only speculate about the reasons to close it; but upon rereading your post, I wonder what your question is. Your post begins stating you want to simulate: that would be off-topic as purely a coding question. The rest provides some reactions, such as "this is counter-intuitive," but I cannot find any actual question in it. – whuber Mar 12 '24 at 15:25

0 Answers0