File:Khintchine inequality (svg).svg
From testwiki
Jump to navigation
Jump to search
Original file (SVG file, nominally 768 × 768 pixels, file size: 409 KB)
Contents
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionKhintchine inequality (svg).svg |
English: Khintchine inequality illustrated with random points in the complex plane.
import matplotlib.pyplot as plt
import numpy as np
def khintchine_experiment(N, num_trials=1000):
complex_numbers = np.random.randn(N) + 1j * np.random.randn(N)
sums = []
for _ in range(num_trials):
# Generate random signs (+1 or -1)
signs = np.random.choice([-1, 1], size=N)
# Multiply complex numbers by random signs and sum them
current_sum = np.sum(complex_numbers * signs)
sums.append(current_sum)
# Calculate the expected modulus
expected_modulus = np.sqrt(np.sum(np.abs(complex_numbers)**2))
return complex_numbers, sums, expected_modulus
# Parameters for the experiment
N = 10 # Number of complex numbers
num_trials = 3000
# Run the experiment
complex_numbers, sums, expected_modulus = khintchine_experiment(N, num_trials)
# Plotting
plt.figure(figsize=(8, 8))
# Plot the original complex numbers
plt.scatter(
[x.real for x in complex_numbers],
[x.imag for x in complex_numbers],
color='blue',
label='$x_i}},
marker='x'
)
# Plot the resulting sums
plt.scatter(
[s.real for s in sums],
[s.imag for s in sums],
color='black',
alpha=0.1,
s=5,
label='$\sum \epsilon_i x_i{{))}}
)
# Plot circles representing the expected modulus range
circle_avg = plt.Circle((0, 0), np.mean(np.abs(sums)), color='red', fill=False, linestyle='--', label=f'$\\mathbb{{E{{))}}\\mid\\sum_i \epsilon_i x_i\\mid{{))}})
circle_expected = plt.Circle((0, 0), expected_modulus, color='purple', fill=False, linestyle='-.', label=f'$\sqrt{{\sum_i \\mid x_i \\mid^2{{))}})
plt.gca().add_patch(circle_avg)
plt.gca().add_patch(circle_expected)
plt.title(f'Khintchine Inequality (N={N}, Trials={num_trials})')
plt.legend()
plt.xticks([]), plt.yticks([])
plt.axis('equal') # Ensure circles are displayed as circles
plt.show()
|
| Date | |
| Source | Own work |
| Author | Cosmia Nebula |
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
This media file is uncategorized.
Please help improve this media file by adding it to one or more categories, so it may be associated with related media files (how?), and so that it can be more easily found.
Please notify the uploader with {{subst:Please link images|File:Khintchine inequality (svg).svg}} ~~~~ |
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
some value
419,230 byte
image/svg+xml
db686732264a1971e5860f737d77de2356f5eb2e
17 January 2025
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 04:37, 18 January 2025 | 768 × 768 (409 KB) | wikimediacommons>Cosmia Nebula | Uploaded while editing "Khintchine inequality" on en.wikipedia.org |
File usage
There are no pages that use this file.