I want to find the index/location of a randomly chosen number in a 1D NumPy array within the array itself, but when I try the following:  a = np.array(np.linspace(1,10,10)) b = np.random.choice(a) print(a.index(b))   It doesn't work and can't figure out where the problem is. Does anyone have an idea?  Thanks in advance!  EDIT: how do you only index the randomly chosen value if the values in the NumPy array are identical, for example:  a = np.array(np.linspace(10,10,10))
I know there is a method for a Python list to return the first index of something:  &gt;&gt;&gt; l = [1, 2, 3] &gt;&gt;&gt; l.index(2) 1   Is there something like that for NumPy arrays?
Let$\ p_n$ be the$\ n$-th prime. Can you give me a proof for$\ \prod_{i=1}^\infty \frac{p_i-1}{p_i}=P\approx \frac{1}{11.0453}$? I found$\ \prod_{i=1}^\infty \frac{p_i}{p_i-1}\approx 11.0453$ on . Moreover, writing a paper, should one provide a proof or it is trivial? Thanks in advance. What are the best books to study Neural Networks from a purely mathematical perspective? I am looking for a book that goes through the mathematical aspects of neural networks, from simple forward passage of multilayer perceptron in matrix form or differentiation of activation functions, to back propagation in CNN or RNN (to mention some of the topics).  Do you know any book that goes in depth into this theory? I've had a look at a couple (such as Pattern Recognition and Machine Learning by Bishop or Deep Learning by Goodfellow, Bengio and Courville) but still have not found a rigorous one (with exercises would be a plus). Do you have any suggestions? How do I print all lines of a file with duplicate values in a certain column Given a file like this:  1,768,12,46576457,7898 1,123,435,134,146 2,345,6756856,12312,1311 5,234,567465,12341,1341 1,3245,4356345,2442,13 9,423,2342,121,463 9,989,342,121,1212   I would like to list all rows (in bash terminal) such that the value in column 1 appears at least twice (in column 1). The result should be  1,768,12,46576457,7898 1,123,435,134,146 1,3245,4356345,2442,13 9,423,2342,121,463 9,989,342,121,1212 This questions has been asked before too and I did go through most of the suggestions. Things I have tried so far: setting up correct  path variable environment, installing anaconda 32 bits, python 2.7, or even switching to python 2.7 in cmd while initially using Anaconda 3 , adding Desktop 10.4.pth file with  following path.  C:\Program Files (x86)\ArcGIS\Desktop10.4\bin C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcToolBox\Scripts   I also added those paths in environment variable   These suggestions help me to reduce the error. But Now I am getting a different error. Looks like python can find arcpy but missing another package.  Getting this error while trying to import arcpy in python 3.6.   File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line 22, in &lt;module&gt;     from arcpy.geoprocessing import gp    File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in &lt;module&gt;     from _base import *  ModuleNotFoundError: No module named '_base'   Any suggestions? Why is physical space equivalent to $\mathbb{R}^3$? Georeferencing scanned map using ArcMap? redirecting openshift rhcloud domain to custom domain for SEO purposes Openshift application url: example.rhcloud.com  Custom domain: example.com  I came across this  and added the redirection rule. However, I can not access example.rhcloud.com now. My custom domain is www.example.com.  To avoid duplicate content problems, I tried this redirection.   Here is my .htaccess file:  RewriteEngine on   # Uncomment the following lines to force HTTPS #RewriteCond %{HTTP:X-Forwarded-Proto} !https  #RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]   # WordPress Defaults RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]  # Redirect Https traffic to Http RewriteEngine on  RewriteCond %{SERVER_PORT} ^443$ [OR] RewriteCond %{HTTPS} on RewriteRule  ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]   # Redirect non-www to www RewriteEngine on  RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]    # Redirect openshift rhcloud domain to custom domain RewriteEngine on  RewriteCond %{HTTP_HOST} ^example.rhcloud.com$ RewriteRule (.*)$ http://www.example.com/$1 [R=301,L]   Why is example.com not redirecting to ww.example.com? How do I fix this?  Also, I see that since I have https to http redirection and non www to www redirection, my blog has been loading slow. How can I reduce it to lesser number of rules?  Edit:  In chrome:   In Firefox:     The page isn't redirecting properly, Firefox has detected that the server is redirecting the request for this address in a way that will never complete.     This problem can sometimes be caused by disabling or refusing to accept cookies. What does limit actually mean? I have been in a deep confusion for about a month over the topic of limits! According to our book, the limit at $a$ is the value being approached by a function $f(x)$ as $x$ approaches $a$.  I have a doubt that in real number line we can never ever reach the closest value to $a$ because always a more closer value will exist.  Now when talking about our methods for calculating limit, what method comes in our mind when we have to calculate where the value approaches? Let's say we have to find what value $f(x)$ approaches when $x$ moves from $[0,a)$.  So we calculate the value of $f(x)$ at $x=0$, say $4$, and then at $x\to a$.   But the problem is that we don't know the value $x\to a$, so we say the value is $a-h$ where $h\to 0$ and calculate the value of $f(a-h)$, say $5-h$.  Now here is where my doubt starts! In the final step we put the value of $h=0$ say in that it is an infinitesimal quantity.  My doubt is that $h$ was tending to $0$ means that it was never equal to zero  maybe it is infinitesimally small, not a stationary value, not an imaginable value, but we know for sure that it is not  equal to $0$. Maybe it is the point closest to zero, but it is not equal to zero and when we use the result $5-h=5$ we are actually making an error which is tending to zero. Maybe the error is very small, but still, there is some error in that we cannot calculate it but we can see that there is this infinitesimal error present.  That means we don't get the exact limiting value or last value of $f(x)$.  $x$ belongs to $[0,a)$ but a value approximate to infinitesimal? Isn't it right! We get an approximated value? What is a good, short, word to describe a software engineer? What should I call a person who write software, computer programs ? I know he/she is a software engineer, can I call him/her as "Coder"? Let $R$ be a commutative ring with 1 then why does $a\in N(R) \Rightarrow 1+a\in U(R)$? Let $R$ be a commutative ring with 1, we define  $$N(R):=\{ a\in R \mid  \exists k\in \mathbb{N}:a^k=0\}$$  and  $$U(R):=\{ a\in R \mid a\mbox{ is invertible} \}.$$  Could anyone help me prove that if $a\in N(R) \Rightarrow 1+a\in U(R)$?  I've been trying to construst a $b$ such that $ab=1$ rather than doing it by contradiction, as I don't see how you could go about doing that. Change the display scaling on the fly I'm looking for a keyboard shortcut or a CLI instruction to change the display scale on the fly. Seems there's nothing in compiz-config manager to handle this? I was writing some Unit tests last week for a piece of code that generated some SQL statements.  I was trying to figure out a regex to match SELECT, INSERT and UPDATE syntax so I could verify that my methods were generating valid SQL, and after 3-4 hours of searching and messing around with various regex editors I gave up.  I managed to get partial matches but because a section in quotes can contain any characters it quickly expands to match the whole statement.  Any help would be appreciated, I'm not very good with regular expressions but I'd like to learn more about them.  By the way it's C# RegEx that I'm after.  Clarification  I don't want to need access to a database as this is part of a Unit test and I don't wan't to have to maintain a database to test my code. which may live longer than the project. A linking verb is a verb which connects a subject to its predicate   without expressing an action. A linking verb is used to re-identify or   describe its subject.      Ex:      Alan is a beast.      Alan seems drunk.   But I would say that some linking verbs can be used with "continuous tenses" &amp; other linking verbs can not, but I am not sure.      (linking verb) to experience a particular feeling or emotion      Ex: I’m feeling a little better today.      Do you still feel hungry?   So, feel in this meaning can be used with continuous tenses  But I would think this sentence "Do you still feel hungry?" does not make much sense because it uses "simple present tense" which expresses something that happens regularly. Noone would feel hungry regularly.  So, that sentence "you feel hungry" would mean "you always feel hungry".      (linking verb) (not used in the progressive tenses): to have a   particular physical quality which you become aware of by touching         adj.         The water feels warm.      Its skin feels really smooth.    says "Speakers sometimes use the Simple Present to express the idea that an action is happening or is not happening now. This can only be done with Non-Continuous Verbs and certain Mixed Verbs."  so, "The water feels warm." could mean "The water is always warm" (simple present expressing things that happen regularly - more or less permanent action)  But "The water feels warm." could mean "The water is warm now" (simple present with non-continuous verb expressing things that is happening now - a temporary action)     : (linking verb) to seem; to appear         adj.         to look pale/happy/tired      That book looks interesting.   In dictionary,      (linking verb) (not used in the progressive tenses): to   give the impression of being or doing something         adj.         She didn't appear surprised at all.       (to somebody) (to be) something (not used in the progressive tenses): to give the impression of being or doing something (synonym:   appear)         adj.         You seem happy.   So, we cannot say "you are seeming happy" or "you are appearing happy".  But I am not sure I can say "You are looking good" (sounds right to my ears) or "That book is looking interesting." (doesn't sound right to my ears)  But we can say "The future’s looking good." ()  So, some verbs has the same meaning but one can be used with "continuous" &amp; the other can not, right?  Ex: "you are looking happy", but "you seem happy". Find $\int \frac{x^3}{x^2-1} \:\mathrm{d}x$ Find $\displaystyle \int \dfrac{x^3}{x^2-1} \:\mathrm{d}x$.   I think there are a few ways to do this. We could just break this up using long division or break it up into partial fractions then use long division. My homework says to break this up into its roots so that's why I brought up partial fractions. Is that the best way to do it here? Counting inversions in an array I'm designing an algorithm to do the following: Given array A[1... n], for every i &lt; j, find all inversion pairs such that A[i] &gt; A[j]. I'm using merge sort and copying array A to array B and then comparing the two arrays, but I'm having a difficult time seeing how I can use this to find the number of inversions. Any hints or help would be greatly appreciated. How do I install iTunes on Ubuntu? I've tried different ways to install iTunes, but to no avail. I tried with Wine, but it didn't work. Is it possible to have iTunes on Ubuntu? What should I do if my Windows computer seems to be infected with a virus or malware?  What are the symptoms of an infection? What should I do after noticing an infection? What can I do to get rid of it? how to prevent from infection by malware?   This question comes up frequently, and the suggested solutions are usually the same. This community wiki is an attempt to serve as the definitive, most comprehensive answer possible. Feel free to add your contributions via edits. GCD in polynomial rings with coefficients in a field extension An $n$th root inequality: $\sqrt[n]{n} < 1 + \sqrt{2/n}$ Prove that for any positive integer $n$,       $$n^{1/n}  &lt; 1 + \sqrt{\frac{2}{n}}.$$   This due to Victor Linis, Eureka, Vol. 2, No. 2, February 1976, p. 29.   Hint:      Use the binomial theorem. Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors?