Starter exercises on scientific computing (Python) [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am interested in learning the basics of scientific computing, but sadly in my daily life I don't encounter problems or situations in which I get to code something to solve a mathematical problem (Or any problem whatsoever, other than the basic programming things we are asked to do).
I know the basics of python and I'm not worried about it since I can always learn what I need on the go, but I need a resource (A book, website or mailing list will do) with problems and exercises I can use to start working with the kind of situations I could encounter if I decide to work in this in the future.
I've looked around but I haven't seen anything aimed for people knowing programming but not knowing the specific details of scientific computing, just advanced things I don't understand at the moment.

When I first started learning to program I used Project Euler. It is a series of challenging mathematical/computer programming problems that will require logical and mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems. The problems themselves are interesting, and they gradually increase in difficulty.
Be careful though - it can become quite addictive!
Here's the link: https://projecteuler.net

You might try [About Project Euler] (http://projecteuler.net/) and Problems
The problem are interesting and can be done using different languages. Since the problems have different complexities, and the different languages may allow better (or not as good) programming solutions, this would seem to be a good site to study.

Related

Using machine learning to detect fish spawning in audio files [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 months ago.
Improve this question
My friend is doing his thesis related to fish spawning in rivers, for this, he collects hours of data that he then analysis manually in Audacity and looks for specific patterns in the spectrograms that might indicate the sound of fish spawning.
Since he has days' worth of data I proposed a challenge to myself: to create an algorithm that might help him in detecting these patterns.
I am fairly new to Machine Learning, but a junior in programming and this sounds like a fun learning experience.
I identify the main problems as:
samples are 1 hour in length.
noise in the background (such as cars and the rivers)
Is this achievable with machine learning or should I look into other options? If yes which ones?
Thank you for taking the time to read!
the first step would be to convert the sound signals into features that machines can understand. Maybe look into MFCCs for that.
Given that you have an appropriate feature representation of your problem domain, the main thing to consider would be what kind of machine learning algorithm would you apply? Unless you would like to sit and annotate hours of data, naive supervised learning is out of the window.
I think your best bet would be to modify VAD (voice activity detection) algorithms or better yet, Speaker recognition/Identification modals.
You could also approach it by first having a complex enough representation that allows you to "see" the sound and comparing it with every frame in the test data of the specific length. Might be useful to check out DTW (Dynamic Time warping)
If you have not designed such modals before, it will be a bit difficult and might take quite a long time.

Order of constraints in Python Z3 for best speed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm writing a z3 python program that is running a bit slow. The reason why it is running slow is because there is one part of the program where I am adding many harder constraints in nested for loops. My instructor told us that adding equality constraints would make the program run faster in terms of limiting the possibilities the program goes through when the line Solver().check() is reached.
I'm wondering whether I should be adding the equality constraints before the "harder" constraints to make it go faster, or whether the equality constraints should go after the "harder" constraints?
I would want the equality constraints to be checked first to limit possibilities of the harder constraints, so I would assume s.add(x == y), or something should be added first so that it is checked first?
These sorts of questions come often; and the honest answer is that the performance of the solver on any given question relies on many factors. Changing the order of constraints should in general have no effect, but in practice it usually does. (See https://github.com/Z3Prover/z3/issues/5559 as an example.) Even renaming variables (something you'd think that'd have no effect) can change performance. (See here, for instance: https://github.com/Z3Prover/z3/issues/5147)
If you're having performance problems, it's best to address it as a modeling issue: i.e., how can you formulate your problem so it's "easier" to solve; instead of thinking about how to "reorder" the constraints, which is a never-ending guessing game. I suggest you actually post your actual encoding and ask about specific advice regarding that problem. Your question is unanswerable in the sense that there's no single strategy that will work well in all cases.

Is there a way to compute the cosets of D<sub>2n</sub> in <i>S</i><sub><i>n</i></sub> [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Although this is a question of maths but I really wanted to figure out if something like this is possible or not by coding it .(preferably in C). I had the question posted in mathsstackexchange where I saw that there's a way to find out the cosets of D_12 in S_6 by using Python programming. Can someone just help me to figure out how are we doing this?
S_n is the group formed by all possible permutations of n-elements and D_2n is formed by the generators <r, s> where r =(123, n) and s=(1n)(2 n-1).
Here's the link to the answer
https://math.stackexchange.com/questions/3880306/find-the-cosets-of-d-2n-in-s-n
Also I am not accustomed to posting questions in stackoverflow, I really don't know how to add mathematical symbols.
Though the logic remains same, the implementation will vary from Python to c due to difference is data types and so on. So you should try learning Python, it’s very easy to learn and you can pick up writing code in Python within few days considering you already you know a few other languages. And writing such complex programs can be easy in Python due to the vast inbuilt libraries and readability. So it’s better if you learn Python and start implementing this in Python.

Is it bad practice to mix OOP and procedural programming in Python (or to mix programming styles in general) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have been working on a program to solve a Rubik's cube, and I found myself unsure of a couple of things. Firstly, if I have a bunch of functions that have general applications (e.g., clearing the screen), and don't know whether or not I should change them to methods inside of a class. Part of my code is OOP and the other part is procedural. Does this violate PEP8/is it a bad practice? And I guess in broader terms, is it a bad idea to mix two styles of programming (OOP, functional, procedural, etc)?
I would say it's not bad at all, if the problem can be solved more easily that way and that your language supports it.
Programming paradigms are just different approaches to solving problems:
Procedural says "What are the steps that need to be performed to solve this problem?"
Functional says "What values should be transformed and how should they be transformed to solve this problem?"
OOP says "What objects need to interact with one another and what messages are needed to be sent between them to solve this problem?"
When you divide up your problem into smaller ones, you might find that some parts of the problem can be solved more easily in a functional way, other parts a procedural way. It's totally possible to have such a problem.
Python is mainly procedural and quite OOP, and has functional features (namely functools). It's not as functional as Haskell and not as OOP as C#, but it allows you to use those paradigms to some extent.

Optimal Length of a Python Function (Style) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Perhaps this is not the correct place to ask this question, and part of me thinks that there is no real answer to it, but I'm interested to see what experienced Python users have to say on the subject:
For maximum readability, concision, and utility, what is a range for an optimal length of a Python function? (Assuming that this function will be used in combination with other functions to do something useful.)
I recognize that this is incredibly dependent on the task at hand, but as a Sophomore Comp. Sci. major, one of the most consistent instructions from professors is to write programs that are comprised of short functions so as to break them up into "simple", discrete tasks.
I've done a big of digging, including through the Python style guide, but I haven't come up with a good answer. If there are any experienced Python users that would like to weigh in on this subject, I would appreciate the insight. Thanks.
I'm sure a lot of people have strong opinions about this, but for new programmers a good rule of thumb is to try and keep it below 10-20 lines. A better rule of thumb is that a function should do one thing and do that one thing well. If it becomes really long, it is likely doing more than one thing and can be broken down into several functions.

Categories

Resources