-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Fix markdown for normal distribution quicksort #4875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,18 +1,15 @@ | ||||||
# Normal Distribution QuickSort | ||||||
|
||||||
|
||||||
Algorithm implementing QuickSort Algorithm where the pivot element is chosen randomly between first and last elements of the array and the array elements are taken from a Standard Normal Distribution. | ||||||
This is different from the ordinary quicksort in the sense, that it applies more to real life problems , where elements usually follow a normal distribution. Also the pivot is randomized to make it a more generic one. | ||||||
|
||||||
This is different from the ordinary quicksort in the sense, that it applies more to real life problems, where elements usually follow a normal distribution. Also the pivot is randomized to make it a more generic one. | ||||||
|
||||||
## Array Elements | ||||||
|
||||||
The array elements are taken from a Standard Normal Distribution , having mean = 0 and standard deviation 1. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a link to Standard Normal Distribution |
||||||
|
||||||
#### The code | ||||||
### The code | ||||||
|
||||||
```python | ||||||
|
||||||
>>> import numpy as np | ||||||
>>> from tempfile import TemporaryFile | ||||||
>>> outfile = TemporaryFile() | ||||||
|
@@ -22,12 +19,11 @@ The array elements are taken from a Standard Normal Distribution , having mean = | |||||
>>> np.save(outfile, X) | ||||||
>>> print('The array is') | ||||||
>>> print(X) | ||||||
|
||||||
``` | ||||||
|
||||||
------ | ||||||
|
||||||
#### The Distribution of the Array elements. | ||||||
### The Distribution of the Array elements | ||||||
|
||||||
```python | ||||||
>>> mu, sigma = 0, 1 # mean and standard deviation | ||||||
|
@@ -38,27 +34,18 @@ The array elements are taken from a Standard Normal Distribution , having mean = | |||||
|
||||||
``` | ||||||
|
||||||
------ | ||||||
|
||||||
----- | ||||||
|
||||||
|
||||||
|
||||||
|
||||||
 | ||||||
|
||||||
--- | ||||||
|
||||||
--------------------- | ||||||
 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the one in Wikimedia: https://upload.wikimedia.org/wikipedia/commons/thumb/2/25/The_Normal_Distribution.svg/1280px-The_Normal_Distribution.svg.png, which is in public domain |
||||||
|
||||||
-- | ||||||
------ | ||||||
|
||||||
## Plotting the function for Checking 'The Number of Comparisons' taking place between Normal Distribution QuickSort and Ordinary QuickSort | ||||||
|
||||||
```python | ||||||
>>>import matplotlib.pyplot as plt | ||||||
|
||||||
|
||||||
# Normal Disrtibution QuickSort is red | ||||||
# Normal Disrtibution QuickSort is red | ||||||
>>> plt.plot([1,2,4,16,32,64,128,256,512,1024,2048],[1,1,6,15,43,136,340,800,2156,6821,16325],linewidth=2, color='r') | ||||||
|
||||||
#Ordinary QuickSort is green | ||||||
|
@@ -68,8 +55,4 @@ The array elements are taken from a Standard Normal Distribution , having mean = | |||||
|
||||||
``` | ||||||
|
||||||
|
||||||
---- | ||||||
|
||||||
|
||||||
------------------ | ||||||
------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so well written. Could you also improve it?