Algorithm Definition and 651 Threads

  1. T

    Algorithm for dB vs time graph for one frequency from FFT?

    I'm doing a physics experiment for school, for which I am measuring the reverb time for specific frequencies in a room. What I did was record a 1000 Hz sound, and some time after it, and looked at its FFT on Audacity to see the intensity of just 1000 Hz at a given time. Manually, I can do this...
  2. Superposed_Cat

    Is There an Error in My Q Deep Learning Algorithm? Need Help Troubleshooting!

    [mentor note: code blocks added for readability and syntax hilighting] Hey all, been trying to implement a Q deep learning algorithm, having an issue though, its not working, after 100 000 game plays and using 1000 iterations to train each step (although i have tried lower numbers for both)...
  3. B

    Pseudocode for Karplus-Strong algorithm

    Does anyone have some Pseudocode for Karplus-Strong algorithm?
  4. Uriel

    A Problem with a convolution algorithm

    Hi. I've been reading "Statistical Mechanics Algorithms and Computations". And I came to a problem while processing Algorithm 1.26 (I attach a link at the end). I don't get why the weights are the way they are, specially I can't understand the sequence {1/2l,1/l,...,1/l,1/2l}. Does anyone...
  5. L

    MHB Prim's algorithm for minimal spanning tree

    Quite stuck on this how do i do this and how do i document each step?
  6. M

    I Why does +bc become negative in the proof of the Euclidian Algorithm?

    In this video, at 5:35 He has d/(a-qb) for the first part. I was not sure how he got that. Why is it not d/(a+qb)? Because d/a and d/bc implies d/(a+bc) Why does +bc become negative?
  7. evinda

    MHB Is it the algorithm the optimal one?

    Hello! (Wave) I want to write an optimal algorithm that solves the following problem: Someone chooses a number from the set $\{ 1, \dots,1000\}$ and I have to find it. I can ask if the number that was chosen is $< , > , \leq $ or $ \geq $ from a number and the possible answers are yes or no...
  8. benarceneaux

    Proving n^2 + 3n^3 is Θ(n^3) for n >= 0

    First off I'm studying for an exam tomorrow, this isn't homework. Also, I've already written the proof and verified I've gotten the correct answer. I'm here to ask some questions about the solution that I am not completely confident I understand. Here's the problem: Prove that n2 + 3n2 is Θ(n3)...
  9. A

    I Simon's Algorithm: Solving the Mystery of f(x+s)

    Hi all, I am sure some of you have heard of Simon's algorithm that calculates a secret string s when given a black box. Basically, let's say we have a qubit x that is n digits long. Now the black box contains a function f that outputs f(x+s) where s is the mystery string and + is bit-wise modulo...
  10. S

    Djikstra's algorithm with distance 1 between every node

    Does anyone know whether there exists a specialized Djikstra's algorithm for when every node has the same distance between it? Or to think of it another way, an algorithm for simply finding the minimum number of moves to get from 1 node to another? e.g. in the following A - B - C...
  11. lionliam96

    CNC acc/dec look ahead algorithm

    Homework Statement I`m having some trouble with an acceleration/deceleration look ahead algorithm I`m trying to implement in a CNC controller written in C#/F#, specifically the algorithms treatment of time. Homework Equations The white paper can be found at...
  12. Avatrin

    Python Exploring Algorithmic Composition and MIDI Programming with Python

    Python is the only programming language I know, and I know there is a huge library of MIDI music out there. I want to play around with machine learning and algorithmic composition to see what I can produce. So, what books should I read to be able to do this? What I am looking for is: Books to...
  13. S

    Largest permutation of elements in the range 1,....,N

    with at most k swaps. (In other words, like the largest number formed by swapping k digits.) Example. A=[4,2,3,5,1], k = 1 ---> [5,2,3,4,1] I'm wondering why my algorithm is failing the test cases which I'm unable to see. using System; using System.Collections.Generic; using System.IO...
  14. S

    Algorithm to find the smallest substring containing a set of....

    characters in a specified amount. I've been working on this for 10+ hours and can't seem to get it right. It passes all the unit tests I've written, but when I use it in the context of the program I'm writing it fails. The idea is like ACTAGACC { A : 2, C : 1} ------> 4, because smallest...
  15. S

    Largest number formed by replacing k digits

    I'm wondering if you guys can help me figure out where I'm going wrong here. The prompt is Given k and an n-digit number, help Sandy determine the largest possible number she can make by changing k digits. Full prompt here: https://www.hackerrank.com/challenges/richie-rich My solution is...
  16. dholbach

    A Barabasi-Albert Algorithm for Generating Scale-Free Graphs

    I've been working on implementing the Barabasi-Albert model in C++. Barabasi-Albert networks are supposed to be scale-free -- that is, their degree distribution is supposed to be power-law distributed. In order to test whether my program was working correctly, I plotted the degree distribution...
  17. S

    JavaScript Algorithm to return all subarrays of a given array

    I can't find this exact algorithm anywhere on the internet. What I'm trying to implement is the following function // Returns all subarrays of the given array, not including the empty array // ex. [a,b,c].subarrays() = [ [a], [b], [c], [a,b], [a,c], [b,c], [a,b,c] ] Array.prototype.subarrays...
  18. JesseJC

    Counting floating point operations in an algorithm

    Hey guys, another question regarding MatLab here. In this assignment, I need to create a function of 'k' to count the number of floating point operations in the algorithm that I've made. Here is my code so far: expAk = zeros(1000, 1000); load('CA3matrix.mat'); times = zeros(15, 1); for j =...
  19. anorlunda

    I Making a quantum computer do Shor's algorithm

    I think I understand quantum superposition and entanglement, and a qubit. I just finished reading Scott Aaronson's brilliant blog post "Shor I'll Do It" that allowed me to understand Shor's Algorithm and how it relates to QM. But now I'm missing the next step. How does one "wire up" a number...
  20. M

    A Algorithm creates representative set of data

    Hi all, I have algorithm to analyze and make it easier to implement in programming language (Python). We have table with data and we want to select only representative part. It looks like: ID_PRODUCT | CARDINALITY | SET VARIANCE WITH THIS ELEMENT AND ABOVE 10 ---------------- 110...
  21. S

    Proof of optimality of algorithm

    Homework Statement Given an array of positive integers A[1, . . . , n], and an integer M > 0, you want to partition the array into segments A[1, . . . , i1], A[i_1 + 1, . . . , i2], . . . , A[i_k−1 + 1, . . . , ik], so that the sum of integers in every segment does not exceed M, while...
  22. TheMathNoob

    Why does this sorting algorithm properly sort the array?

    Homework Statement Consider the following sorting algorithm for an array of numbers (Assume the size n of the array is divisible by 3): • Sort the initial 2/3 of the array. • Sort the final 2/3 and then again the initial 2/3. Reason that this algorithm properly sorts the array. What is its...
  23. A

    MHB Master algorithm design and upper bound proof

    Hello, I am currently preparing myself for exams and I have a past exam question which I can't solve. This question concerns online learning and the following picture illustrates it: Is anyone able to help me out and propose a solution to this question?
  24. J

    Finding a Local Minimum in a Complete Binary Tree with Log(N) Probes

    Homework Statement Consider a complete binary tree T with n nodes (n = 2^d − 1 for some d). Each node v of T is labeled with a distinct real number x. Define a node v of T to be a local minimum if the label x is less than the label y for all nodes m that are joined to v by an edge. You are...
  25. J

    Find p in a Sorted Array with Unique Property | O(log n) Algorithm

    Homework Statement Suppose you are given an array A of n distinct integers with the following property: There exists a unique index p such that the values of A[1 . . . p] are decreasing and the values of A[p . . . n] are is increasing. For instance, in the example below we have n = 10 and p =...
  26. A

    MHB How Does the DeBoor Algorithm Calculate Coefficients for Spline Fitting?

    Hi, I'm trying to implement the DeBoor algorithm for Spline fitting to data points. In the subroutine BSPLPP (which is used to convert the B representation to PP representation), the COEF array is of the size (k,l). But for a kth degree polynomial, the number of coefficients should be (k+1). I...
  27. Kingyou123

    Recursive Algorithm, does it look correct

    Homework Statement Homework Equations s1=1,sn=(sn-1) +n, and n>=2 The Attempt at a Solution It looks correct, but I'm not sure it'll work for negative values.[/B]
  28. kevin2016

    A What is the closed-form solution using ALS algorithm to optimize

    C \in \mathbb{R}^{m \times n}, X \in \mathbb{R}^{m \times n}, W \in \mathbb{R}^{m \times k}, H \in \mathbb{R}^{n \times k}, S \in \mathbb{R}^{m \times m}, P \in \mathbb{R}^{n \times n} ##{S}## and ##{P}## are similarity matrices (symmetric). ##\lambda##, ##\alpha## and ##\beta## are...
  29. wololo

    Efficiently Finding Cycles in a Graph: A Scientific Exploration

    Homework Statement Homework Equations Recursion, graphs, DFS The Attempt at a Solution To try to solve this algorithm, I first need to find all the basic cycles in the Graph G. When I have these cycles, I can simply pick the smallest edge in each of them and add them to the set F, while...
  30. newjerseyrunner

    Algorithm gives wrong answer, what's wrong?

    I have a point inside of a triangle and I want to move it to a position on the hypotenuse in the direction normal to it. The triangle's tip is located at position (l, b), the original point inside of it is located at (x, y). The triangle's sides have lengths w and h. That makes the measure of...
  31. M

    Shor's algorithm, definition of modulo

    Hi guys, My question shouldn't take too long to be answered but I simply can't find anything using a google search. It's more of a problem from number theory rather than a physical one. I am referring to the Wikipedia article to Shor's algorithm and I still can't get my head around how the...
  32. X

    Why is the complexity class expression this?

    I'm trying to understand complexity class algorithms off of my professor's lecture notes, but I still can't get a hang of it. void sort(int a[], int N) { //N is the length of the array for (int base=0; base<N; ++base) for (int check=base+1; check<N; ++check) if...
  33. S

    Issue with behavior of ray-plane intersection algorithm

    I'm trying to determine the point, in 3D space, where an arbitrary line/ray intersects with an infinite plane. Using an article on Wikipedia, I tried to reproduce the presented formulas in code. This seems to work fine so long the ray is emitted from the origin of the coordinate system (0, 0...
  34. H Smith 94

    Verlet algorithm: Why am I getting this output?

    Hi! I am currently trying to write a code in C to simulate the orbit of planets around the Sun in the solar system. I am using the velocity Verlet approach and finding that my code produces no acceleration in the ##y##-direction (aside from for ##t_n = 0##,) and that the planet just flies off...
  35. ORF

    Is there any algorithm to find coincidences between 2 lists?

    Hello I need to find coincidences between items in 2 lists. The lists have disordered items, so the first idea I had was to sort the items in the correct order and then finding the coincidences would be easy. The main problem is the big amount of items in the lists. I was using "double-linked...
  36. iamjon.smith

    Comp Sci C++ search algorithm with 3 sublists

    Homework Statement This is the assignment instructions:[/B] In C++, code a search algorithm that searches a list of strings for a particular song. The searching algorithm will have two inputs: the playlist, which is a string array that contains a list of songs in alphabetical order; and a...
  37. evinda

    MHB Solving System of Restrictions with Simplex Algorithm

    Hello! (Wave) I want to apply the simplex algorithm that finds the vertices of the following system of restrictions: $$2x_1+3x_2-x_3+4x_4=8 \\ -x_1+2x_2-6x_3+7x_4=3 \\ x_i \geq 0, i=1,2,3,4$$ I took at the beginning the basic feasible solution non degenerate solution $(1,2,0,0)$ and I wrote...
  38. gre_abandon

    Demon algorithm for microcanonical ensemble

    I simulated a microcanonical ensemble of 10 ideal gas particles in one dimension and yielded the expected normal distribution of velocities. However, I still did not get how the algorithm works. The demon has non-negative energy content and the demon together with the system constitutes a closed...
  39. barbara

    MHB Algorithm Type: Postorder Tree | Correct?

    + / \ / \ * - / \ / \ 2 3 * +...
  40. jedishrfu

    Landmark Algorithm for Graph Isomorphism

    Quanta Magazine published this article on a potentially new algorithm for graph isomorphism by Prof Laszlo Babai of the University of Chicago: https://www.quantamagazine.org/20151214-graph-isomorphism-algorithm/ There's a reference to the Arxiv preprint here: http://arxiv.org/abs/1512.03547v1
  41. wololo

    Tree Data Structures & Minimax Algorithm for Games

    Homework Statement Homework Equations Tree data structures. I think it might also have something to do with minimax algorithm, but it was only mentioned once and never discussed extensively in class so I doubt it is required. The Attempt at a Solution [/B] If both players play as well as...
  42. S

    Is this considered a valid sorting algorithm?

    Let me know if I've invented a valid [FONT=Courier New]O(n) sorting algorithm. public void Sort ( this List<T> L ) { // Check every second whether L is sorted // Given enough time, natural bit flips will eventually make L sorted while ( !L.IsSorted() ) Thread.Sleep(1000); }...
  43. TheMathNoob

    Algorithm to find the minimum spanning tree on a planar graph

    Homework Statement I have the following algorithms: Prime MST with array, Prime MST with priorityq and Kruskal with priorityq. I have to choose the best algorithm to find the minimum spanning tree on a planar graph. A planar graph has the property in which the number of edges is in O(number of...
  44. W

    Can the Velocity Verlet Algorithm Prove Energy Conservation?

    I've read that this algorithm conserves energy if the system it's applied to conserves energy. I can't find a proof, and it's not a particularly obvious statement, so how would you prove it?
  45. S

    Help me nail the final post to the fence of this algorithm

    I'm writing a class to format console output and the trickiest method in this class so far is the one for printing a table. I'm having it act like an HTML table in how text fits public static void PrintTable ( string[][] cells ) { // Outputs content in cells matrix...
  46. G

    Optimization algorithm to apply to my system?

    I am at the moment working on a project in which I try to minimize the annual running costs of a chemical manufacturing plant. To predict annual running costs I created a model with over 50 inputs, including things such as the type of chemicals and equipment used at different points in the...
  47. B

    Does this algorithm guarantee equaprobable outcomes?

    Suppose you have a list of numbers, say ##{1, 7, 9, 4, 5, 6}##. You store the first number, and then iterate through this list. For each number in the list, you flip a coin. If it is heads, you swap that element in the list with the number you stored. If tails, you do nothing. Either way, you...
  48. P

    Iterations in the Euclidean algorithm

    Homework Statement Let m and n be natural numbers. Suppose ## min(m, n) \geq 2^k ## for some natural number k. Show that the Euclidean Algorithm needs at most ## 2k ## iterations to calculate the gcd of m and n.The Attempt at a Solution [/B] So far I think I need to show that for all the...
  49. TheMathNoob

    Average complexity -- worst case of an algorithm

    Homework Statement a Write an algorithm to find the median of three distinct integers a,b,c b Describe D, the set of inputs for your algorithm, in light of the discussion in Section 1.4.3 following Example 1.9. This section discusses Average complexity for an algorithm which involves an...
  50. NATURE.M

    Solving the a7 + b7 = c7 + d7 Equation Using Heap Algorithm

    Homework Statement We have four integers a,b,c,d each of which are >= 1 and <= n, and are asked to write an algorithm to find all possible solutions to the following equation: a7 + b7 = c7 + d 7 The algorithm should use a heap of at most n elements, and should have worst case runtime of O(n2...
Back
Top