Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7015835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:42:16+00:00 2026-05-27T22:42:16+00:00

[ EDIT : The fmin() method is a good choice for my problem. However,

  • 0

[EDIT: The fmin() method is a good choice for my problem. However, my problem was that one of the axes was a sum of the other axes. I wasn’t recalculating the y axis after applying the multiplier. Thus, the value returned from my optimize function was always returning the same value. This gave fmin no direction so it’s chosen multipliers were very close together. Once the calculations in my optimize function were corrected fmin chose a larger range.]

I have two datasets that I want to apply multipliers to to see what values could ‘improve’ their correlation coefficients.

For example, say data set 1 has a correlation coefficient of -.6 and data set 2 has .5.

I can apply different multipliers to each of these data sets that might improve the coefficient. I would like to find a set of multipliers to choose for these two data sets that optimizing the correlation coefficients of each set.

I have written an objective function that takes a list of multipliers, applies them to the data sets, calculates the correlation coefficient (scipy.stats.spearmanr()), and sums these coefficients. So I need to use something from scipy.optimize to pass a set of multipliers to this function and find the set that optimizes this sum.

I have tried using optimize.fmin and several others. However, I want the optimization technique to use a much larger range of multipliers. For example, my data sets might have values in the millions, but fmin will only choose multipliers around 1.0, 1.05, etc. This isn’t a big enough value to modify these correlation coefficients in any meaningful way.

Here is some sample code of my objective function:

def objective_func(multipliers):
    for multiplier in multipliers:
        for data_set in data_sets():
            x_vals = getDataSetXValues()
            y_vals = getDataSetYValues()
            xvals *= muliplier
            coeffs.append(scipy.stats.spearmanr(x_vals, y_vals)

    return -1 * sum(coeffs)

I’m using -1 because I actually want the biggest value, but fmin is for minimization.

Here is a sample of how I’m trying to use fmin:

print optimize.fmin(objective_func)

The multipliers start at 1.0 and just range between 1.05, 1.0625, etc. I can see in the actual fmin code where these values are chosen. I ultimately need another method to call to give the minimization a range of values to check for, not all so closely related.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:42:17+00:00Added an answer on May 27, 2026 at 10:42 pm

    Multiplying the x data by some factor won’t really change the Spearman rank-order correlation coefficient, though.

    >>> x = numpy.random.uniform(-10,10,size=(20))
    >>> y = numpy.random.uniform(-10,10,size=(20))
    >>> scipy.stats.spearmanr(x,y)
        (-0.24661654135338346, 0.29455199407204263)
    >>> scipy.stats.spearmanr(x*10,y)
        (-0.24661654135338346, 0.29455199407204263)
    >>> scipy.stats.spearmanr(x*1e6,y)
        (-0.24661654135338346, 0.29455199407204263)
    >>> scipy.stats.spearmanr(x*1e-16,y)
        (-0.24661654135338346, 0.29455199407204263)
    >>> scipy.stats.spearmanr(x*(-2),y)
        (0.24661654135338346, 0.29455199407204263)
    >>> scipy.stats.spearmanr(x*(-2e6),y)
        (0.24661654135338346, 0.29455199407204263)
    

    (The second term in the tuple is the p value.)

    You can change its sign, if you flip the signs of the terms, but the whole point of Spearman correlation is that it tells you the degree to which any monotonic relationship would capture the association. Probably that explains why fmin isn’t changing the multiplier much: it’s not getting any feedback on direction, because the returned value is constant.

    So I don’t see how what you’re trying to do can work.

    I’m also not sure why you’ve chosen the sum of all the the Spearman coefficients and the p values as what you’re trying to maximize: the Spearman coefficients can be negative, so you probably want to square them, and you haven’t mentioned the p values, so I’m not sure why you’re throwing them in.

    [It’s possible I guess that we’re working with different scipy versions and our spearmanr functions return different things. I’ve got 0.9.0.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: an important piece might be that I'm calling a cfc method via ajax...
Edit: From another question I provided an answer that has links to a lot
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
Edit: I'm looking for solution for this question now also with other programming languages.
EDIT I had a problem a while ago writing a program in C which
EDIT After staring at this for 2 days, I do see one issue. I
EDIT: Sorry about ellipsis that's not what I actually have. For declaring an array
EDIT I tried debugging this with xdebug and netbeans. It's weird that the exports
EDIT: Updated thanks to @daroczig's lovely answer below. However, test 2 still feels like
EDIT: This seems to be a problem with IE exclusively. Very simple to re-create,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.