def _stereo_arc(x,
                y,
                xy=None,
                north=(1, 0, 0),
                right=(0, 1, 0),
                translation=-1,
                **kwds):
    from sage.misc.functional import n
    x = vector(x)
    y = vector(y)
    sx = n(
        _stereo_coordinates(x,
                            north=north,
                            right=right,
                            translation=translation))
    sy = n(
        _stereo_coordinates(y,
                            north=north,
                            right=right,
                            translation=translation))
    if xy == None:
        xy = x + y
    sxy = n(
        _stereo_coordinates(xy,
                            north=north,
                            right=right,
                            translation=translation))
    return _arc(sx, sy, sxy, **kwds)
def _stereo_arc(x,y, xy=None,  north=(1,0,0), right=(0,1,0), translation=-1, **kwds):
    from sage.misc.functional import n
    x=vector(x)
    y=vector(y)
    sx=n(_stereo_coordinates(x, north=north, right=right, translation=translation))
    sy=n(_stereo_coordinates(y, north=north, right=right, translation=translation))
    if xy == None:
        xy=x+y
    sxy=n(_stereo_coordinates(xy, north=north, right=right, translation=translation))
    return _arc(sx,sy,sxy,**kwds)                                                               
Exemple #3
0
def curve(nb_equipes, max_points=100, K=1, R=2, base=2, verbose=False):
    r"""
    INPUT:

    - ``nb_equipes`` -- integer
    - ``max_points`` -- integer
    - ``K`` -- the value at ``p = nb_equipes``
    - ``R`` -- real (default: ``2``), curve parameter
    - ``base`` -- 2
    - ``verbose`` - bool 

    EXEMPLES::

        sage: from slabbe.ranking_scale import curve
        sage: curve(20, 100)
        -99*(p*(log(40) + 1) - p*log(p) - 20*log(40) + 20*log(20) -
        20)/(19*log(40) - 20*log(20) + 19) + 1
        sage: curve(64, 100)
        99*(p*(7*log(2) + 1) - p*log(p) + 64*log(64) - 448*log(2) -
        64)/(64*log(64) - 441*log(2) - 63) + 1

    ::

        sage: curve(64, 100)(p=64)
        1
        sage: curve(64, 100)(p=1)
        100
        sage: curve(64, 100)(p=2)
        198*(32*log(64) - 218*log(2) - 31)/(64*log(64) - 441*log(2) - 63) + 1
        sage: n(curve(64, 100)(p=2))     # abs tol 1e-10
        95.6871477097753

    ::

        sage: curve(64, 100, verbose=True)
        fn = -(p*(7*log(2) + 1) - p*log(p) + 64*log(64) - 448*log(2) - 64)/log(2)
        aire = 147.889787576005
        fn normalise = 99*(p*(7*log(2) + 1) - p*log(p) + 64*log(64) - 448*log(2) - 64)/(64*log(64) - 441*log(2) - 63) + 1
        99*(p*(7*log(2) + 1) - p*log(p) + 64*log(64) - 448*log(2) - 64)/(64*log(64) - 441*log(2) - 63) + 1

    The base argument seems to be useless (why?)::

        sage: curve(100,100,base=3)
        -99*(p*(log(200) + 1) - p*log(p) - 100*log(200) + 100*log(100) -
        100)/(99*log(200) - 100*log(100) + 99) + 1
        sage: curve(100,100,base=2)
        -99*(p*(log(200) + 1) - p*log(p) - 100*log(200) + 100*log(100) -
        100)/(99*log(200) - 100*log(100) + 99) + 1
        
    """
    from sage.symbolic.assumptions import forget, assume
    from sage.misc.functional import integrate, n
    from sage.functions.log import log
    from sage.calculus.var import var
    x, p = var('x,p')
    forget()
    assume(p - 1 > 0)
    assume(p - nb_equipes < 0)
    fn = integrate(
        log(R * nb_equipes, base=base) - log(x, base=base), x, p, nb_equipes)
    if verbose: print "fn = %s" % fn
    aire = fn(p=1)
    if verbose: print "aire = %s" % n(aire)
    fn_normalise = fn / aire * (max_points - K) + K
    if verbose: print "fn normalise = %s" % fn_normalise
    return fn_normalise
Exemple #4
0
def curve(nb_equipes, max_points=100, K=1, R=2, base=2, verbose=False):
    r"""
    INPUT:

    - ``nb_equipes`` -- integer
    - ``max_points`` -- integer
    - ``K`` -- the value at ``p = nb_equipes``
    - ``R`` -- real (default: ``2``), curve parameter
    - ``base`` -- 2
    - ``verbose`` - bool 

    EXEMPLES::

        sage: from slabbe.ranking_scale import curve
        sage: curve(20, 100)
        -99*(p*(log(40) + 1) - p*log(p) - 20*log(40) + 20*log(20) -
        20)/(19*log(40) - 20*log(20) + 19) + 1
        sage: curve(64, 100)
        -33*(p*(7*log(2) + 1) - p*log(p) - 64*log(2) - 64)/(19*log(2) + 21) + 1

    ::

        sage: curve(64, 100)(p=64)
        1
        sage: curve(64, 100)(p=1)
        100
        sage: curve(64, 100)(p=2)
        66*(26*log(2) + 31)/(19*log(2) + 21) + 1
        sage: n(curve(64, 100)(p=2))     # abs tol 1e-10
        95.6871477097753

    ::

        sage: curve(64, 100, verbose=True)
        fn = -(p*(7*log(2) + 1) - p*log(p) - 64*log(2) - 64)/log(2)
        aire = 147.889787576005
        fn normalise = -33*(p*(7*log(2) + 1) - p*log(p) - 64*log(2) - 64)/(19*log(2) + 21) + 1
        -33*(p*(7*log(2) + 1) - p*log(p) - 64*log(2) - 64)/(19*log(2) + 21) + 1

    The base argument seems to be useless (why?)::

        sage: curve(100,100,base=3)
        -99*(p*(log(200) + 1) - p*log(p) - 100*log(200) + 200*log(10) - 
        100)/(99*log(200) - 200*log(10) + 99) + 1
        sage: curve(100,100,base=2)
        -99*(p*(log(200) + 1) - p*log(p) - 100*log(200) + 200*log(10) -
        100)/(99*log(200) - 200*log(10) + 99) + 1
        
    """
    from sage.symbolic.assumptions import forget, assume
    from sage.misc.functional import integrate, n
    from sage.functions.log import log
    from sage.calculus.var import var
    x,p = var('x,p')
    forget()
    assume(p - 1 > 0)
    assume(p-nb_equipes < 0)
    fn = integrate(log(R*nb_equipes, base=base) - log(x, base=base), x, p, nb_equipes)
    if verbose: print("fn = %s" % fn)
    aire = fn(p=1)
    if verbose: print("aire = %s" % n(aire))
    fn_normalise = fn / aire * (max_points - K) + K
    if verbose: print("fn normalise = %s" % fn_normalise)
    return fn_normalise