All Questions

Tagged with
Filter by
Sorted by
Tagged with
3 votes
2 answers
95 views

SineCosine Wave

As a beginner this is my first code. Any comments? ...
Arpit's user avatar
  • 131
4 votes
2 answers
4k views

Cython with variable-length arrays

Dynamically growing arrays are a type of array. They are very useful when you don't know the exact size of the array at design time. First you need to define an initial number of elements. (Wikipedia) ...
user4933's user avatar
  • 149
8 votes
1 answer
125 views

Using get_dummies to create a Simple Recommender System - Cold Start

Question: was using get_dummies a good choice for converting categorical strings? I used get_dummies to convert categorical ...
john taylor's user avatar
2 votes
1 answer
87 views

Forecasting stock market data using Support Vector Regression

I coded this Support Vector Regression (SVR) myself following some equations in a journal (see here, or here (not in English)). The loss function used by the journal and the code below is mean ...
Ihsanul's user avatar
  • 23
4 votes
0 answers
72 views

Importer for binary datafile of PI88 Nanoindenter

As an exercise, I want to rewrite a C++ program to import measurement files (and later create excelsheets, reports ...). The measurement files split in 2 files, a binary file, and a xml-file. Because ...
natter1's user avatar
  • 288
5 votes
1 answer
596 views

Beginning of a GUI Python solution to Andrew Ng's ML week 3 excercises

Coursera has a course for beginning Machine Learning and the code is written in Octave. This is the beginning of a solution to the week 3 exercises but written in python. Instead of a terminal app I'...
ao222's user avatar
  • 53
1 vote
1 answer
179 views

k-armed bandit problem in Python

I implemented k-armed bandit problem in C#, MATLAB and Python. C# and Matlab code run fairly fast (With same settings of T = 2000 and nRun = 1000 the elapsed time is about 6sec). However, the Python ...
Omid's user avatar
  • 159
16 votes
1 answer
388 views

Solve the phase state between two haplotype blocks using markov transition probabilities

I have spent about more than a year in python, but I come from biology background. I should say I have got some understanding of for-loop and nested-for-loop to workout the solution to the problem I ...
everestial007's user avatar
5 votes
1 answer
206 views

Using NumPy to scale data in 2 out of 3 columns

The below code takes a csv containing age, weight, height and prints the betas determined through linear regression to an output csv. It runs for 10 iterations using a different alpha for each, and ...
user7875185's user avatar
5 votes
1 answer
4k views

Applying Laplacian smoothing to vertices in a mesh

I'm totally new in Python and I wrote some code. It is a simple algorithm to smooth objects. I need to find adjacent vertices in mesh and sum their coordinates and after that divide by a number of ...
Pagorek's user avatar
  • 51
3 votes
0 answers
275 views

Simple finite difference employing Maccormack technique

I am relatively new to programming and while I am fairly comfortable with the math, I cannot say with confidence that I feel the same way with programming. Anyway here is a simple finite difference ...
N.K's user avatar
  • 31
4 votes
2 answers
320 views

Randomly generate a list with predetermined mean

Aim: randomly generate \$n\$ numbers between \$a\$ and \$b\$ with (roughly) mean \$m\$. Problem: The simple beginner's code I wrote becomes very inefficient as \$m\$ moves away from \$\frac{a + b}{2}\...
user2738815's user avatar
12 votes
3 answers
602 views

Plotting different parameterized polynoms

For a university assignment I had to plot different polynomial functions depending on one single parameter. That parameter gave the number of supporting points to interpolate a given function in the ...
Vogel612's user avatar
  • 25.2k
5 votes
1 answer
194 views

Calculating a table of deBroglie wavelengths for various electron energies

Here is the formula for the deBroglie wavelength of an electron versus its kinetic energy: $$ \lambda(E_k) = h\left/\sqrt{\frac{(E_k+m_eC^2)^2-m_e^2C^4}{C^2}}\right.$$ and here is simple script that ...
Christian Chapman's user avatar
6 votes
1 answer
1k views

Python! (Snake)

This is now an Iterative Review. Next Iteration Nowhere near a full game yet. Just a basic overview and initialisation of a Snake() class. Thoughts? ...
Kaz's user avatar
  • 8,790
7 votes
1 answer
2k views

Koch snowflake in Python with numpy and pygame

I've drawn a Koch snowflake with Python 3. I'm new to the Python world and would appreciate all feedback on how to make the code more Pythonic as I'm not used to these idioms, styles and modules. All ...
Anna's user avatar
  • 275
6 votes
2 answers
270 views

Picking seats in a matrix

I'm trying to write a Python class that creates a matrix of zeros, then uses a random number generator to pick 'seats' on the matrix. It changes the zero in that seat to a one, until the matrix is all ...
Mardux's user avatar
  • 61
2 votes
2 answers
5k views

Simulation of 2D elastic balls

Following this SO post and this Wikipedia article, I wrote a Python script to simulate physics of 2D elastic balls. I define the physical behaviour of each ball in the ...
cromod's user avatar
  • 329
5 votes
1 answer
252 views

Comparing FFTs to deduplicate IVR recordings

I've got a Python script that traverses two file trees, checking all .wav files for duplication. I'm still an undergrad, and have never worked with audio before. I'm not entirely sure this is going ...
Will's user avatar
  • 153
12 votes
2 answers
17k views

Generating a 3D Point Cloud

I'm trying to produce a 3D point cloud from a depth image and some camera intrinsics. The image is 640x480, and is a NumPy array of bytes. The output is a (rows * columns) x 3 array of points. I've ...
dorfy's user avatar
  • 121
4 votes
1 answer
146 views

Look up parameters based on a numpy array of input values

Aim: Write a function that looks up empirical parameters A, B and C for a solar radiation ...
Fred S's user avatar
  • 143
4 votes
1 answer
53 views

Printer Color Templates

I'm new to Python and I just wrote my first program with OOP. The program works just fine and gives me what I want. Is the code clear? Can you review the style or anything else? ...
ipsissimus's user avatar
5 votes
1 answer
5k views

Fixed point iteration and cobweb plot

I'm using Python to find fixed points of a given function and then draw a cobweb plot to visualize it. Thanks to this question, I have the core of the code written and can accomplish the task, but I ...
eeyore's user avatar
  • 53
7 votes
2 answers
299 views

Taking wind data and simulating future wind profiles

I am new to programming, and am using Python to take wind data and simulate future wind profiles. The code as written takes a while to execute and I was hoping someone could suggest ways to make my ...
andrewrmunro's user avatar
8 votes
2 answers
30k views

K-means clustering in Python

The following code uses scikit-learn to carry out K-means clustering where \$K = 4\$, on an example related to wine marketing from the book DataSmart. That book uses excel but I wanted to learn Python ...
Martin Leslie's user avatar
1 vote
1 answer
3k views

Parse Bloomberg Excel/CSV with Pandas DataFrame

I retrieved Bloomberg data using the Excel API. In the typical fashion, the first row contains tickers in every fourth column, and the second row has the labels Date, PX_LAST, [Empty Column], Date, ...
user3529051's user avatar
2 votes
1 answer
915 views

Performance problems with 1D cellular automata experiment in Python with Numpy

I'm an experienced programmer but relatively new to Python (a month or so) so it's quite likely that I've made some gauche errors. I very much appreciate your time spent taking a look at my code. My ...
otakucode's user avatar
  • 123