Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [algorithm]

Questions about algorithms used or which might be used to implement a procedure known by name or loosely but not in detail. The subject of the question may be a procedure mentioned in the literature or a Mathematica built-in function

3
votes
1answer
38 views

Mathematica package to calculate the graph crossing number

I have been searching for a mathematica package that can calculate the graph Crossing number of a (small) given arbitrary graph (the graphdata of known graphs doesn't help me). Before I write my own ...
1
vote
0answers
68 views

How can we make an algorithm with the A* method in Mathematica with 5 different flight routes? [duplicate]

I need to find the shortest path with the A* algorithm using Mathematica. I have 5 different flight routes with coordinates. They start and end at the same point. Between every point there is a wind ...
2
votes
3answers
66 views

How can I compute the chromatic number of a graph?

I'm starting in Wolfram Mathematica. I saw that MinimumVertexColoring [g] could be used to calculate the chromatic number of a graph, but ...
3
votes
1answer
81 views

Identify emotions from a drawn face using machine learning?

Can someone tell me how you could modify this code so that it recognizes more facial expressions? ... thanks for the help. ...
6
votes
1answer
445 views

Which algorithm does Mathematica use for “RandomSearch”?

Recently I have used Mathematica for minimization of certain functions and I have realized that even though it lasts much longer, the method "RandomSearch" functions much better than the other methods ...
4
votes
1answer
214 views

Pythagorean quadruples

I am very interested in the problem that deals with the Pythagorean quadrruples, which are listed in rosettacode. Unfortunately, I have not been able to find any way to compute them with Mathematica. ...
7
votes
1answer
330 views

Why is SVM unable to separate linearly separable data?

I have two sets of data, namely blue and yellow. I manually added a point {8, -3} to the blue data. ...
3
votes
0answers
132 views

How to achieve with Mathematica the effect a closure has in other languages?

Motivation I want to write an auxiliary function (brief auxf) for testing the output of another function that evaluates its body repeatedly using ...
3
votes
1answer
106 views

How to improve the simulation speed?

I'm new here. Actually, Mathematica is so cool, I can just write about 5 lines to do the same thing comparing to over 100 lines in Python. But the speed is very slow. I wonder if there is any method ...
7
votes
2answers
124 views

Generating permutations

I have a list of different combinations of letters of the alphabet {{"a"}, {"b"}, {"c"}, {"a", "b"}, {"a", "c"}, {"b", "c"}} There is no pattern to them - that ...
0
votes
2answers
67 views

An Integrate result is not what it should be

Recently, I come across an algorithm called HyperLogLog (https://stackoverflow.com/questions/12327004/how-does-the-hyperloglog-algorithm-work). There's a magic number in it, and when reading the paper,...
10
votes
1answer
166 views

Quick QuickSort implementation

I am playing with julialang and loving it, but at the same time noticed that they have a benchmark comparison with Mathematica. I have already submited a better version of ...
3
votes
1answer
70 views

What algorithm is used by FindGeometricTransform? [closed]

Can anyone tell me how the operation FindGeometricTransform[pts1, pts2] works (I mean inside logic of the transformation function), or where can I find such an ...
5
votes
2answers
133 views

How to mark leaves of polynomial based on its position in tree

I've been struggling with this for a few days, and so I thought I might ask this here. Part of the problem lies in the fact that I do not even know the mathematical solution, which runs the risk of ...
1
vote
1answer
144 views

Find a few eigenvalues of a HUGE sparse Hermitian matrix

I know that methods such as Arnoldi and FEAST can be employed to only find a few eigenvalues. But now I need to add another ...
1
vote
3answers
78 views

Filter results those are failed to converge

I have this code ...
0
votes
1answer
153 views

Using the binary search algorithm in a sorted grid

I want to get a mathematica code for binary search algorithm applied to a sorted grid containing integers. For example, given f[k_,x_]= x^2 + k x + k - 2 where <...
0
votes
0answers
69 views

What method Mathematica uses to solve a quadratic system

I'am writing a paper and I need to know what method Mathematica uses to solve a quadratic system by default. This is my system: ...
6
votes
2answers
550 views

How to calculate the “center” point

I have such points pts = Uncompress[FromCharacterCode[ Flatten[ImageData[Import["http://i.stack.imgur.com/zEP05.png"],"Byte"]]]]; ListPlot[pts] If I use the ...
3
votes
3answers
2k views

Algorithm too slow

Writing: nn = 10; Table[Sum[Length[Select[DeleteDuplicates[Map[Sort, Tuples[ {1, 2, 5, 10}, i]]], Total[#] == n &]], {i, 1, n}], {n, 1, nn}] I get: {...
0
votes
0answers
30 views

Using space to denote multiplication [duplicate]

When I want to impress a Mathematica novice I show him how we can use spaces to denote multiplication (telling him also to be careful not to forget the space as in ...
6
votes
2answers
275 views

Improve my implementation of the Diamond square algorithm

Some time ago, I began to explore the magnificent world of the terrain generation using the computer. Investigating on the Internet know about the existence of the diamond square algorithm. Try to ...
4
votes
1answer
164 views

solid partitions generator

According to Wikipedia, a solid partition of $n$ is a three-dimensional array $n_{i,j,k}$ of non-negative integers (with indices $i,j,k \geq 1$) such that $$\sum_{i,j,k} n_{i,j,k}=n$$ and $$n_{i+1,j,k}...
3
votes
1answer
247 views

Metropolis-Hastings Algorithm Problem

I've been trying to implement the Metropolis-Hastings algorithm for a while but there seems to be something weird going on. This algorithm does not need as much of the statistics to understand, and ...
6
votes
4answers
397 views

How to speed up this high-dimensional definite integral?

Examples ➤ 1. $$I=\iiint\limits_D \dfrac{{\rm d}x\ \!{\rm d}y\ \!{\rm d}z}{(x+y+z)^p}~,$$ where $$D=\{~(x,y,z)~\colon~x>0~,y>0~,z>0~,x+y+z<1~\}~.$$ MMA gives: $~I=-\dfrac1{2(p-3)}~.$ ➤...
2
votes
2answers
88 views

I want to improve my algorithm of knowing eigenvalues of the matrix H(k)

I want to improve my algorithm. I want to know the eigenvalues of below n-dimensional matrix H. When n=10, the matrix H is like below. Now, $To$ and $M$ are constants and $T1$ and $T2$ are functions ...
4
votes
2answers
193 views

Numerical Join of two sets of vectors ignoring repeats

I have two sets of numerical vectors which can be either Real or Complex and I want to combine them together, ignoring repeats. ...
2
votes
1answer
160 views

How to visualize elastic collision among particles confined in a square 2D container?

I've already simulate two particle confined in a square 2D container, but I don't know how to simulate the elastic collision between them. Currently, they just pass through each other without any ...
1
vote
1answer
126 views

Creating subsets of lists of lists which have certain properties

PREFACE: This question is about a proper algorithm and its implementation. I will explain the problem as detailed as possible and will give my current algorithm as well as two more possible solutions ...
1
vote
2answers
297 views

How to convert from C to Mathematica?

I am trying to understand what is explained in this webpage, in the section entitled "Generating noise with different power spectra laws". After reading that section, I thought I could do it in ...
2
votes
1answer
98 views

3D binning keeping the values

I have N points in the from of triplets {xi,yi,zi}. I would like to bin them on a grid ...
0
votes
2answers
139 views

Testing that an algorithm has converged

It's frequent that when writing some kind of algorithm (numerical integration, clustering, whathaveyou) I'll want to say "Stop the algorithm and return the result when some error $\epsilon$ is below ...
1
vote
1answer
294 views

Allan Deviation Algorithm

I am trying to write my own Allan Deviation calculator in Mathematica using the definition, $$\sigma(\tau)^{2}=\frac{1}{2M-2}\sum_{i=1}^{N-1}(\bar{y}_{i+1} - \bar{y}_{i})^{2}\text{.}$$ Where the $\bar{...
11
votes
1answer
460 views

3D tree in Mathematica?

Searching the web for information about the affine transformation, I found the one page, which called my attention for the tree that show and is this but unfortunately do not give information about ...
1
vote
0answers
56 views

Finding same output values by varying input values of function

I have written a function in Mathematica that needs five input variables. The function outputs a single real number. The underlying model is a complex model for option pricing. To ease things up, let ...
8
votes
3answers
266 views

From a list of lists of integer, choose a minimal length list of integers that intersects each sublist

I have this list of lists of integers between 1 and 255. ...
4
votes
0answers
233 views

Problem with the accuracy of the real-coded Genetic algorithm

Since there is no Genetic algorithm implemented in the Mathematica i tried to write a very simple genetic algorithm myself. The accuracy of the results depend upon rounding up the obtained parameters. ...
-1
votes
1answer
58 views

While condition

I have the following code: While[Total[{0,1,3}] != 2, {0,1,3} -(#[[Ordering[Max[] & /@ #]]])] I want to decrease the maximum coefficient of the vector ...
17
votes
3answers
744 views

Image segmentation by pixel value

I'm looking for a way to segment a grayscale image (or a 2D array) by its pixel values. We look at two neighboring pixels, if their values are close within a certain threshold, then we say they are ...
2
votes
0answers
43 views

Dean's apportionment

I would like to program Dean's apportionment. https://www.maa.org/press/periodicals/convergence/apportioning-representatives-in-the-united-states-congress-deans-method-of-apportionment Here is my ...
0
votes
0answers
67 views

Algorithm that will trim a unique ID number and produce a shorter unique ID

I have a unique ID number with 2^128 magnitude length (128 bits). This means ~3.4e+38 which is quite large that my actually needs, spending valuable time in a transmission protocol. There is a ...
1
vote
1answer
64 views

Lowndes' apportionment

I am trying to program Lowndes' apportionment but i got some problems. Indeed the total of allocated seats is not equal to the disponible seats . Here is my code ...
11
votes
3answers
224 views

Creating unique keys from list [duplicate]

I have the following (example) list: list = {"b", "a", "b", "b", "a", "c", "c", "c", "d", "b", "aa"}; and want to distinguish its elements by appending a counter ...
4
votes
2answers
155 views

Adams apportionment

I am trying to program the Adams' apportionment algorithm. I have a problem when the minimum position corresponds to a party which won no seats. When I run the code, it gives me a set like ...
6
votes
3answers
194 views

How to efficiently get the Complement of a Domain and several Intervals (IntervalComplement?)

Suppose you have a list of intervals (or tuples), such as: intervals = {{3,7}, {17,43}, {64,70}}; And you wanted to know the intervals of all numbers not ...
2
votes
2answers
117 views

Locally randomizing a path on a graph

I have a walk $v_1 \ldots v_n$ on a graph $G$ and I want to apply the following operation to it: I wish to choose two indexes, $l$, $k$, and replace the sub-path from $v_l$ to $v_k$ with one of the ...
4
votes
1answer
97 views

How to implement an iterative Lucy algorithm in Mathematica?

I am trying to implement the Lucy algorithm that the authors of this paper use to get a distribution of diffusion coefficients from the distribution of displacements. The equation looks like this. $$...
3
votes
0answers
89 views

Mathematica algorithms made possible with Wolfram's NKS?

In Wolfram's NKS he mentions that the Rule-30 Cellular Automata is used as a random number generator in Mathematica. What other algorithms in Mathematica have been made possible with Wolfram's NKS?
4
votes
0answers
668 views

How to find the a minimum cost perfect matching

Crossposted on Wolfram Community A a minimum cost perfect matching is very useful tool.This three links about this demand just related me,let alone all MMA.SE. How to get some pairing with smallest ...