I'm calculating key rate (R^Rate-wise) by integrating R(eta) over all possible eta from 0 to 1, with a probability distribution (PDTC) which is a log-normal distribution.
The equation of log-normal distribution:
The equation of R(eta):
Therefore, R^Rate-wise =...
I'm interested in quantum programming. So far I've managed to use Java and Python inside Datamelt computation project for physics simulations and for various statistical plots. Now I want to make a simple code that illustates quantum computing, and maybe even to visualize its principles (for...
Hi
I have a list of 3D angular velocities (a numerical solution to an ODE). I want to show the trajectory this rotation would cause by mapping it out on the unit sphere. How can I go about doing that? What is the best way to approach this?
I am trying to animate a plot of two distinct points (blue and green points) moving about the complex unit circle using Python's Matplotlib library. The problem I am having is that the animation does not remove and update the previous data points but rather sequentially smears it on the unit...
This is another application of using Taylor recurrences (open access) to solve ODEs to arbitrarily high order (e.g. 10th order in the example invocation). It illustrates use of trigonometric recurrences, rather than the product recurrences in my earlier Lorenz ODE posts.
Enjoy!
#!/usr/bin/env...
Hi All,
I am trying to learn versions 2,3 of Python ( long story). Just curious as to the "Dependency/Compatibility" issues between and within versions 2 and 3. Are packages/libraries in 3.x available for 3.x' where x'>x ? How about for version 2? Specifically, at this point, I am trying to...
Hey everyone!
This might be a bit of a dumb question, but I'm not familiar with much in the programming world. I know a few languages that I've learned on my own (online) or through a course in school (MATLAB). When it comes down to coding outside of MATLAB or a website, I'm not sure where to...
Hi all,
I had shebanged a Python program file to train myself to run Python from the command line or search box. Problem is now I cannot access my old text-based .py files. Every time I click on them to open, they run in the command line. How can I access the text format again?
Hi, I want to plot the vector field ##\vec F = ye^x \hat i + (x^2 + e^x) \hat j + z^2e^z \hat k##
The code I have tried:
# The components of the vector field
F_x = y*e**x
F_y = x**2 + e**x
F_z = z**2*e**z# The grid
xf = np.linspace(-0.15, 2.25, 8)
yf = np.linspace(-0.15, 2.25, 8)
zf =...
Hi,
I want to program an GARCH model for exchange rates. To do this, I calculated the residuals. Next, I did the following (in python)
def main():
vP0 = (0.1, 0.05, 0.92)
a = minimize(garch_loglike, vP0, eps, bounds = ((0.0001, None), (0.0001, None), (0.0001, None))...
I want to make an animation where a (red) ball departs from (0,0) and draws the function ##f(x) = sin x##
This is what I know:
How to plot ##f(x) = sin x##
To do so I followed instructions from the worksheet. Actually I'd have done:
But I guess they want to me to it in that way because...
I asked this question on SO, but I am having problems with it (I cannot even get into my account now). It seems that people using the IP I am using are asking a lot and that limits the number of questions I can ask. Please have a look at my question. Here's the link:
[Moderators note: bold large...
Adapted from this code, which is an implementation of the algorithm described here.
Removed dependency on Numpy
Use as library code or test Himmelblau's function
from copy import copy
from sys import stderr, argv
def replace_worst(data, new):
del data[-1]
data.append(new)
def...
I was reading this wikiperdia article on polyminos (https://en.wikipedia.org/wiki/Polyomino).
The pictures look very nice. Example
I want to learn how to generate these figures myself in an interactive way.
Basically I want to start with a polymino and then I want to be able to translate (by...
Two weeks ago I had no idea on how to code using Python. Now I have completed an online course on functions, loops and strings. However, in that course I did not practice using the specific library called Sympy. Besides, I will use Python in the Physics-Math background, for solving problems like...
I am looking for a book for learning Python so as to compute matrices, eigenvalues, eigenvectors, divergence, curl (i.e vector calculus).
If you also have online recommendations please feel free to write them.
Back in the day, when Perl was my go to language, Programming Perl, the Camel Book, from O'Reilly was The Reference. It was the quick and concise way to get an answer. And you'd probably learn something you weren't necessarily looking for and get a chuckle along the way.
Now that Python is my...
Hello and thanks in advance for your help.
For about a week now, I've been trying to write what should be a simple python program. The idea is first to write a program for a simple harmonic pendulum, then adapt it to a spring pendulum. However, in order to do this, I have to write the simple...
I have four arrays of data xvalues[], yvalues[], zvalues[] and wvalues[] and I want to create, from this data, an interpolated function w = f(x,y,z). Is it easy to do this in python using first a meshgrid and then calling scipy's interpolation?
e.g toy set up is something like, where wvalues...
Hi everyone,
I'm trying to create a sequence that evaluates r for i= 1 to 10 and 100 to 110 ...N (evaluate 10 skip 90 repeats till N).
If python has a GoTo function, I would've used it to return the previous line to repeat. But I couldn't find a function like that anywhere on the internet.
1...
Looking for suggestions on books (or other learning material) that will help me improve my skills using Python for scientific computing. I am comfortable with Python programming (syntax, conditional statements, loops, etc.), and use it for data analysis in my undergraduate experimental physics...
Homework Statement
"Using the time module, write a program that tells one the current time in hours, minutes, and seconds, and time since January the first of 1970."
Homework Equations
import time
% = mod division
int = returns integer value of number
The Attempt at a Solution
import time...
In Keras, the method model.fit() is used to train the neural network. How can I get the output from any hidden layer during training? Consider following code where neural network is trained to add two time series
#multivariate data preparation
#multivariate multiple input cnn example
from numpy...
Hi All,
I am having trouble figuring out how to do extended, i.e., many-lined, comments. I know the format is ( copied from website):
“”””
Problem is that, while I can find the '' in my Qwerty keyboard, I can't figure out how to find the rest in my keyboard. I assume all Qwertys are the...
This is not a question, but a note, which I thought could help students.
I thought I would share this here, as people may be looking for practice problems.
My professor in the Python course I just finished recommended https://projecteuler.net/ as a site to practice using programming skills...
Hi,
I somehow carelessly installed Python 3.72, 32-bit in my 64-bit system. Is this a workable situation or will I pay a price eventually in a conflict between 32-bit software living in a 64-bit system? Should I uninstall and reinstall a 64-bit version?
Dear Sirs,
I have a signal which has an attenuation of 20dB per decade, how do I remove this attenuation using SCIPY? Alternatively how to do it in MATLAB if there are no SCIPY users here?
I'm a SCIPY/MATLAB novice fyg.
Thank you for your kind assistance
Abim
Well I think it is cool anyhow ;)
Here is a dependency-free variable-order double pendulum simulation in about 120 lines of Python. Have you seen the equations of motion for this system?
As usual, this is based on code that I have provided here, but trimmed for maximum impact. Can you see...
Hi everyone,
I am beginner in python programming. So many doubts are being generted in the learing process
Can anyone please explain me how the bitwise NOT (~) operator actually works on values. I have attached a screen short of my textbook (unofficial) with this post and I am confused how...
I have a few of integration equations and need to convert it into Python. The problem is when I tried to plot a graph according to the equation, some of the plot is not same with the original one.
The first equation is the error probability of authentication in normal operation:
cond equation...
Homework Statement
[/B]
This problem is from Mark Newman's Computational Physics, problem 7.9, found at
http://www-personal.umich.edu/~mejn/cp/exercises.html. The problem gives us a blurry convolved image, according to a Gaussian point spread function and our objective is to deconvolve it to...
I have several equations and need to convert it into Python. The problem is that I tried to plot a graph according to the equation. However, the graph that I get is not the same as the original one.
In the paper, the equation of error probability for MIM attack is given by:
First Image
Second...
So I tried solving the differential equation for a spring - mass system using Euler's Algorithm in Python. The equation being
d2x/dt2= -4π2x
(The equation was obtained by Dimensional Analysis)
here x and t are both dimensionless equivalents of position...
I want to write a python program to calculate the Kirkwood−Buff Integrals.
The equation is as:
G=4π∫0 ∞ r 2 [g(r)-1] dr
I have the g(r) values.
Any suggestions are highly appreciated.
Thank you.
Homework Statement
I have a project to make the Solar system on Python, which I have done, but they also require from us to calculate the total energy of the system. We don't have to make the orbits of the planets elliptical, they should be circular and I believe I made them like that. Since...
Hello,
I have found two books that show physics branches with python examples:
This is for mechanics:
https://www.springer.com/us/book/9783319195957
The other on oscillation and waves:
https://www.springer.com/la/book/9783319723136
I see in these books that the University of Oslo is doing...
I have a project to make the solar system. I am trying to start from somwhere. On the notes it says that we need to start by creating a System of Particles
Two-body simulation (Circular motion)
Implement Gravitational acceleration
Each particle (planet) could have its own field.
I.e. Each...
The Earth's magnetic field is cylindrically symmetric and can be described using cylindrical coordinates, (ρ,z,φ). The components of the magnetic field are given by:
(B_φ) = 0
(B_ρ) = −∂A/∂z,
(B_z) =(1/ρ) * ∂(ρA)/∂ρ.
The vector potential for a dipole field is given by
(A_φ) = (B_e)(ρ) *...
I had recently upgraded my version of python from 2 to 3. I had a program that encrypted a text file by converting a character to its Unicode value, altering it and then changing it back to a character using the ord() and chr() methods. This does not seem to work with python 3 and I was...
Features:
No external dependencies.
Arbitrary order simulation (accuracy limited by float precision).
No finite difference errors.
Can be extended to arbitrary precision with gmpy2 and two more lines.
Enjoy!
Parameters:
order
step size
number of steps
initial conditions (x, y, z)
parameters...
Homework Statement
I want to prompt the user to input how many times they want to roll a die, then generate a random number between 1 and 6. I then need to print what their number is and if it is even or odd.
The code I posted below is what I came up with for a single die roll that allows...
Hello
Consider the following code in Python3
n = 226553150
m = 1023473145
n*m = 231871064940156750
int(n*m/5) = 46374212988031352
n*m//5 = 46374212988031350
Now since ##n*m## is divisible by ##5##, both should be give the same answer. But the first is wrong and second is correct. What is...
I am trying to drop the series size so that it matches the size of the dataframe as I need to copy the index value of the series into the df but I am getting mismatch errors. df has a size of 100 but time has a size of 200 so I want to remove the extra rows in time to match df. how can i handle...
I have a dataframe that looks as attached. What I aiming to do is to plot the lines for each type where if it is for type A, I want to be able to have two lines in the graph that shows the trend for type A. I was not able to find any examples online especially with the format of the data in this...
Goal:
I'm trying to allow the user to input varying spellings for certain auto services, and still have my code work properly. My goal was to use the if-else statements to ensure that if the user misspelled a service, the code could correct the error by changing the variable assignment to the...
Homework Statement
I'm making a program to display what I have posted in the image and my program needs to look just like it.
The idea is to have an employee enter information such as their pay and hours worked. Then taxes get calculated and it shows a net amount that the employee has made for...
i have a dataset that has the timestamp data within each row and I am trying to plot the values to see the distribution but have no idea how to do it if the data is presented this way as attached. any ideas? thanks
I would like to convert my joystick's two axis float (horizontal and vertical) to a 360 angle that can be used to set a players direction in my game. From my research, I've found the best route to take is using Atan2.
Variables:
self.rot = 0
horaxis = joy1.get_axis(0)
veraxis = joy1.get_axis(1)...
I am trying to count number of rows that has values in at least 3 columns so the output based on the image shared should be 4. I tried using the code below but it is resulting in the same shape as the whole table which is 7.
counts = df[(df[['a', 'b', 'c', 'd]] != 'no_label').count(axis=1) >= 3]