Python implementation of approximating the chance a particle is at a location after n steps in the cardinal directionsPython implementation of the longest increasing subsequence“Cut the sticks” Python implementationctypes implementation in PythonPython Octree ImplementationAdvent of Code - Day 01Find the longest rectilinear path in a matrix with descending entriesImplementation of the Householder TransformationAnalyzing the U.S. Births dataset in PythonSearching for the location of a sub-image within an imageComputing the autocorrelation between 2D time series arrays in python
What can I do if I am asked to learn different programming languages very frequently?
What if (if any) the reason to buy in small local stores?
A Ri-diddley-iley Riddle
What exactly term 'companion plants' means?
Could Sinn Fein swing any Brexit vote in Parliament?
Do native speakers use "ultima" and "proxima" frequently in spoken English?
How does one measure the Fourier components of a signal?
Constant Current LED Circuit
I got the following comment from a reputed math journal. What does it mean?
Help rendering a complicated sum/product formula
Can a medieval gyroplane be built?
In Aliens, how many people were on LV-426 before the Marines arrived?
Comment Box for Substitution Method of Integrals
What are substitutions for coconut in curry?
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
What should I install to correct "ld: cannot find -lgbm and -linput" so that I can compile a Rust program?
Fewest number of steps to reach 200 using special calculator
How can my new character not be a role-playing handicap to the party?
Is there a hypothetical scenario that would make Earth uninhabitable for humans, but not for (the majority of) other animals?
How do hiring committees for research positions view getting "scooped"?
Why is indicated airspeed rather than ground speed used during the takeoff roll?
Deletion of copy-ctor & copy-assignment - public, private or protected?
Should I use acronyms in dialogues before telling the readers what it stands for in fiction?
Recruiter wants very extensive technical details about all of my previous work
Python implementation of approximating the chance a particle is at a location after n steps in the cardinal directions
Python implementation of the longest increasing subsequence“Cut the sticks” Python implementationctypes implementation in PythonPython Octree ImplementationAdvent of Code - Day 01Find the longest rectilinear path in a matrix with descending entriesImplementation of the Householder TransformationAnalyzing the U.S. Births dataset in PythonSearching for the location of a sub-image within an imageComputing the autocorrelation between 2D time series arrays in python
$begingroup$
Recently, I became very interested in a probability practice problem in my textbook for my class. I decided to implement it in code and I think I got most of it implemented. Right now, I'm hoping to see if there is any possible way that I can improve upon it.
The question reads as follows:
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
The code (and more information) can be found here in the GitHub repository.
The code is right here:
simulation.py
"""
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
"""
from random import choice
import numpy as np
from options import Options
# Directions (K -> V is initial of direction -> (dx, dy)
directions =
'S': (0, -1),
'N': (0, 1),
'E': (1, 0),
'W': (-1, 0)
def get_direction():
"""
Get a random direction. Each direction has a 25% chance of occurring.
:returns: the chosen directions changes in x and y
"""
dirs = "NSEW"
return directions[choice(dirs)]
def change_position(curr_pos, change_in_pos):
"""
Updates the current location based on the change in position.
:returns: the update position (x, y)
"""
return curr_pos[0] + change_in_pos[0], curr_pos[1] + change_in_pos[1]
def increment_counter(counter, end_pos):
"""
Increments the provided counter at the given location.
:param counter: an numpy ndarray with the number of all ending locations in the simulation.
:param end_pos: the ending position of the last round of the simulation.
:returns: the updated counter.
"""
counter[end_pos[1], end_pos[0]] += 1
return counter
def get_chance_of_positions(n):
"""
Gets the approximated chance the particle ends at a given location.
Starting location is in the center of the output.
:param n: The number of steps the simulation is to take.
:returns: the number of iterations and an ndarray with the approximated chance the particle would be at each location.
"""
# The starting position starts at n, n so that we can pass in the location
# into the counter without worrying about negative numbers.
starting_pos = (n, n)
options = Options.get_options()
total_num_of_sims = options.num_of_rounds
counter = np.zeros(shape=(2 * n + 1, 2 * n + 1))
for j in range(total_num_of_sims):
curr_pos = starting_pos
for i in range(n):
change_in_pos = get_direction()
curr_pos = change_position(curr_pos, change_in_pos)
counter = increment_counter(counter, curr_pos)
chances = np.round(counter / total_num_of_sims, decimals=n + 1)
return total_num_of_sims, chances
plot.py
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from simulation import get_chance_of_positions as get_chance
from options import Options
def plot(n):
"""
Saves the plots of the chance of positions from simulation.py
:param n: the number of steps the simulation will take.
"""
num_of_iterations, counter = get_chance(n)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title("Position Color Map (n = )".format(n))
ax.set_xlabel("Number of iterations: ".format(int(num_of_iterations)))
plt.imshow(counter, cmap=plt.get_cmap('Blues_r'))
ax.set_aspect('equal')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(orientation='vertical', cax=cax)
fig.savefig('plots/plot-:03.png'.format(n), dpi=fig.dpi)
def main():
"""
The main function for this file. Makes max_n plots of the simulation.
"""
options = Options.get_options()
for n in range(1, options.num_of_sims + 1):
plot(n)
if __name__ == "__main__":
main()
options.py
import argparse
class Options:
options = None
@staticmethod
def generate_options():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-N', '--num-of-rounds',
type = int,
required = False,
default = 10**5,
help = "The number of rounds to run in each simulation. Should be a big number. Default is 1E5")
arg_parser.add_argument('-n', '--num-of-sims',
type = int,
required = False,
default = 10,
help = "The number of simulations (and plots) to run. Default is 10.")
return arg_parser.parse_args()
@staticmethod
def get_options():
if Options.options is None:
Options.options = Options.generate_options()
return Options.options
I would love for some recommendations on PEP 8, design, and "Pythonic" code (code that Python expects and will thus be better optimized, such as list comprehension and numpy optimizations, wherever they may be.)
python numpy statistics matplotlib
New contributor
$endgroup$
add a comment |
$begingroup$
Recently, I became very interested in a probability practice problem in my textbook for my class. I decided to implement it in code and I think I got most of it implemented. Right now, I'm hoping to see if there is any possible way that I can improve upon it.
The question reads as follows:
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
The code (and more information) can be found here in the GitHub repository.
The code is right here:
simulation.py
"""
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
"""
from random import choice
import numpy as np
from options import Options
# Directions (K -> V is initial of direction -> (dx, dy)
directions =
'S': (0, -1),
'N': (0, 1),
'E': (1, 0),
'W': (-1, 0)
def get_direction():
"""
Get a random direction. Each direction has a 25% chance of occurring.
:returns: the chosen directions changes in x and y
"""
dirs = "NSEW"
return directions[choice(dirs)]
def change_position(curr_pos, change_in_pos):
"""
Updates the current location based on the change in position.
:returns: the update position (x, y)
"""
return curr_pos[0] + change_in_pos[0], curr_pos[1] + change_in_pos[1]
def increment_counter(counter, end_pos):
"""
Increments the provided counter at the given location.
:param counter: an numpy ndarray with the number of all ending locations in the simulation.
:param end_pos: the ending position of the last round of the simulation.
:returns: the updated counter.
"""
counter[end_pos[1], end_pos[0]] += 1
return counter
def get_chance_of_positions(n):
"""
Gets the approximated chance the particle ends at a given location.
Starting location is in the center of the output.
:param n: The number of steps the simulation is to take.
:returns: the number of iterations and an ndarray with the approximated chance the particle would be at each location.
"""
# The starting position starts at n, n so that we can pass in the location
# into the counter without worrying about negative numbers.
starting_pos = (n, n)
options = Options.get_options()
total_num_of_sims = options.num_of_rounds
counter = np.zeros(shape=(2 * n + 1, 2 * n + 1))
for j in range(total_num_of_sims):
curr_pos = starting_pos
for i in range(n):
change_in_pos = get_direction()
curr_pos = change_position(curr_pos, change_in_pos)
counter = increment_counter(counter, curr_pos)
chances = np.round(counter / total_num_of_sims, decimals=n + 1)
return total_num_of_sims, chances
plot.py
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from simulation import get_chance_of_positions as get_chance
from options import Options
def plot(n):
"""
Saves the plots of the chance of positions from simulation.py
:param n: the number of steps the simulation will take.
"""
num_of_iterations, counter = get_chance(n)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title("Position Color Map (n = )".format(n))
ax.set_xlabel("Number of iterations: ".format(int(num_of_iterations)))
plt.imshow(counter, cmap=plt.get_cmap('Blues_r'))
ax.set_aspect('equal')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(orientation='vertical', cax=cax)
fig.savefig('plots/plot-:03.png'.format(n), dpi=fig.dpi)
def main():
"""
The main function for this file. Makes max_n plots of the simulation.
"""
options = Options.get_options()
for n in range(1, options.num_of_sims + 1):
plot(n)
if __name__ == "__main__":
main()
options.py
import argparse
class Options:
options = None
@staticmethod
def generate_options():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-N', '--num-of-rounds',
type = int,
required = False,
default = 10**5,
help = "The number of rounds to run in each simulation. Should be a big number. Default is 1E5")
arg_parser.add_argument('-n', '--num-of-sims',
type = int,
required = False,
default = 10,
help = "The number of simulations (and plots) to run. Default is 10.")
return arg_parser.parse_args()
@staticmethod
def get_options():
if Options.options is None:
Options.options = Options.generate_options()
return Options.options
I would love for some recommendations on PEP 8, design, and "Pythonic" code (code that Python expects and will thus be better optimized, such as list comprehension and numpy optimizations, wherever they may be.)
python numpy statistics matplotlib
New contributor
$endgroup$
add a comment |
$begingroup$
Recently, I became very interested in a probability practice problem in my textbook for my class. I decided to implement it in code and I think I got most of it implemented. Right now, I'm hoping to see if there is any possible way that I can improve upon it.
The question reads as follows:
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
The code (and more information) can be found here in the GitHub repository.
The code is right here:
simulation.py
"""
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
"""
from random import choice
import numpy as np
from options import Options
# Directions (K -> V is initial of direction -> (dx, dy)
directions =
'S': (0, -1),
'N': (0, 1),
'E': (1, 0),
'W': (-1, 0)
def get_direction():
"""
Get a random direction. Each direction has a 25% chance of occurring.
:returns: the chosen directions changes in x and y
"""
dirs = "NSEW"
return directions[choice(dirs)]
def change_position(curr_pos, change_in_pos):
"""
Updates the current location based on the change in position.
:returns: the update position (x, y)
"""
return curr_pos[0] + change_in_pos[0], curr_pos[1] + change_in_pos[1]
def increment_counter(counter, end_pos):
"""
Increments the provided counter at the given location.
:param counter: an numpy ndarray with the number of all ending locations in the simulation.
:param end_pos: the ending position of the last round of the simulation.
:returns: the updated counter.
"""
counter[end_pos[1], end_pos[0]] += 1
return counter
def get_chance_of_positions(n):
"""
Gets the approximated chance the particle ends at a given location.
Starting location is in the center of the output.
:param n: The number of steps the simulation is to take.
:returns: the number of iterations and an ndarray with the approximated chance the particle would be at each location.
"""
# The starting position starts at n, n so that we can pass in the location
# into the counter without worrying about negative numbers.
starting_pos = (n, n)
options = Options.get_options()
total_num_of_sims = options.num_of_rounds
counter = np.zeros(shape=(2 * n + 1, 2 * n + 1))
for j in range(total_num_of_sims):
curr_pos = starting_pos
for i in range(n):
change_in_pos = get_direction()
curr_pos = change_position(curr_pos, change_in_pos)
counter = increment_counter(counter, curr_pos)
chances = np.round(counter / total_num_of_sims, decimals=n + 1)
return total_num_of_sims, chances
plot.py
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from simulation import get_chance_of_positions as get_chance
from options import Options
def plot(n):
"""
Saves the plots of the chance of positions from simulation.py
:param n: the number of steps the simulation will take.
"""
num_of_iterations, counter = get_chance(n)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title("Position Color Map (n = )".format(n))
ax.set_xlabel("Number of iterations: ".format(int(num_of_iterations)))
plt.imshow(counter, cmap=plt.get_cmap('Blues_r'))
ax.set_aspect('equal')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(orientation='vertical', cax=cax)
fig.savefig('plots/plot-:03.png'.format(n), dpi=fig.dpi)
def main():
"""
The main function for this file. Makes max_n plots of the simulation.
"""
options = Options.get_options()
for n in range(1, options.num_of_sims + 1):
plot(n)
if __name__ == "__main__":
main()
options.py
import argparse
class Options:
options = None
@staticmethod
def generate_options():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-N', '--num-of-rounds',
type = int,
required = False,
default = 10**5,
help = "The number of rounds to run in each simulation. Should be a big number. Default is 1E5")
arg_parser.add_argument('-n', '--num-of-sims',
type = int,
required = False,
default = 10,
help = "The number of simulations (and plots) to run. Default is 10.")
return arg_parser.parse_args()
@staticmethod
def get_options():
if Options.options is None:
Options.options = Options.generate_options()
return Options.options
I would love for some recommendations on PEP 8, design, and "Pythonic" code (code that Python expects and will thus be better optimized, such as list comprehension and numpy optimizations, wherever they may be.)
python numpy statistics matplotlib
New contributor
$endgroup$
Recently, I became very interested in a probability practice problem in my textbook for my class. I decided to implement it in code and I think I got most of it implemented. Right now, I'm hoping to see if there is any possible way that I can improve upon it.
The question reads as follows:
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
The code (and more information) can be found here in the GitHub repository.
The code is right here:
simulation.py
"""
A particle starts at (0, 0) and moves in one unit independent
steps with equal probabilities of 1/4 in each of the four
directions: north, south, east, and west. Let S equal
the east-west position and T the north-south position
after n steps.
"""
from random import choice
import numpy as np
from options import Options
# Directions (K -> V is initial of direction -> (dx, dy)
directions =
'S': (0, -1),
'N': (0, 1),
'E': (1, 0),
'W': (-1, 0)
def get_direction():
"""
Get a random direction. Each direction has a 25% chance of occurring.
:returns: the chosen directions changes in x and y
"""
dirs = "NSEW"
return directions[choice(dirs)]
def change_position(curr_pos, change_in_pos):
"""
Updates the current location based on the change in position.
:returns: the update position (x, y)
"""
return curr_pos[0] + change_in_pos[0], curr_pos[1] + change_in_pos[1]
def increment_counter(counter, end_pos):
"""
Increments the provided counter at the given location.
:param counter: an numpy ndarray with the number of all ending locations in the simulation.
:param end_pos: the ending position of the last round of the simulation.
:returns: the updated counter.
"""
counter[end_pos[1], end_pos[0]] += 1
return counter
def get_chance_of_positions(n):
"""
Gets the approximated chance the particle ends at a given location.
Starting location is in the center of the output.
:param n: The number of steps the simulation is to take.
:returns: the number of iterations and an ndarray with the approximated chance the particle would be at each location.
"""
# The starting position starts at n, n so that we can pass in the location
# into the counter without worrying about negative numbers.
starting_pos = (n, n)
options = Options.get_options()
total_num_of_sims = options.num_of_rounds
counter = np.zeros(shape=(2 * n + 1, 2 * n + 1))
for j in range(total_num_of_sims):
curr_pos = starting_pos
for i in range(n):
change_in_pos = get_direction()
curr_pos = change_position(curr_pos, change_in_pos)
counter = increment_counter(counter, curr_pos)
chances = np.round(counter / total_num_of_sims, decimals=n + 1)
return total_num_of_sims, chances
plot.py
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from simulation import get_chance_of_positions as get_chance
from options import Options
def plot(n):
"""
Saves the plots of the chance of positions from simulation.py
:param n: the number of steps the simulation will take.
"""
num_of_iterations, counter = get_chance(n)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title("Position Color Map (n = )".format(n))
ax.set_xlabel("Number of iterations: ".format(int(num_of_iterations)))
plt.imshow(counter, cmap=plt.get_cmap('Blues_r'))
ax.set_aspect('equal')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(orientation='vertical', cax=cax)
fig.savefig('plots/plot-:03.png'.format(n), dpi=fig.dpi)
def main():
"""
The main function for this file. Makes max_n plots of the simulation.
"""
options = Options.get_options()
for n in range(1, options.num_of_sims + 1):
plot(n)
if __name__ == "__main__":
main()
options.py
import argparse
class Options:
options = None
@staticmethod
def generate_options():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-N', '--num-of-rounds',
type = int,
required = False,
default = 10**5,
help = "The number of rounds to run in each simulation. Should be a big number. Default is 1E5")
arg_parser.add_argument('-n', '--num-of-sims',
type = int,
required = False,
default = 10,
help = "The number of simulations (and plots) to run. Default is 10.")
return arg_parser.parse_args()
@staticmethod
def get_options():
if Options.options is None:
Options.options = Options.generate_options()
return Options.options
I would love for some recommendations on PEP 8, design, and "Pythonic" code (code that Python expects and will thus be better optimized, such as list comprehension and numpy optimizations, wherever they may be.)
python numpy statistics matplotlib
python numpy statistics matplotlib
New contributor
New contributor
New contributor
asked 10 mins ago
user3847149user3847149
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
user3847149 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f215632%2fpython-implementation-of-approximating-the-chance-a-particle-is-at-a-location-af%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
user3847149 is a new contributor. Be nice, and check out our Code of Conduct.
user3847149 is a new contributor. Be nice, and check out our Code of Conduct.
user3847149 is a new contributor. Be nice, and check out our Code of Conduct.
user3847149 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f215632%2fpython-implementation-of-approximating-the-chance-a-particle-is-at-a-location-af%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown