PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label overlapping. Show all posts
Showing posts with label overlapping. Show all posts

Thursday, November 17, 2022

[FIXED] How to vertically center an <img> with CSS and NOT overlap a text?

 November 17, 2022     css, html, image, overlapping, vertical-alignment     No comments   

Issue

I'm trying to put a logo in my forum, but neither the engine nor the template I use support this. So I decided to give it a try and put it. It seems so simple, but it's not.

I've tried at least 5 ways I found in the net (mostly from StackOverflow), but they either do not work at all (image not centered vertically) or solve the problem only partially as the image overlaps a text following it.

The only solution which worked in terms of vertical-centering is based on position: absolute and margin: auto

<img src="/EL3232.png" width="32" height="32" style="
        float: left;
        position: absolute;
        top:0;
        bottom:0;
        margin:auto;
">

It has however a side effect: the image overlaps the forum title text.

The HTML is quite complex I would say and its simplification for the post is not easy (a lot of CSS for each preceding element), so I think I will just pass the link to my website, so you knew what I mean: http://www.forumextalife.pl/

It's basically a hierarchy like this: <div> -> <nav> -> <div> -> <div> -> <a>. I want to put an <img> containig the logo inside this <a> tag. To be exact - the element in the website is: <a class="navbar-brand">

I hope you guys can solve it. I've never thought this is gonna be so complicated to have simply an image centered vertically and not overlapping text.


Solution

The cleanest approach is probably to set the image as a background image of .navbar-brand, with a bit of padding and/or line height so that the title aligns appropriately alongside it. Something like this...

.navbar-brand {
   background:url(/EL3232.png) left center no-repeat;
   display:inline-block;
   padding-left:40px;
   height:32px;
   line-height:32px;
} 

Keep responsive design in mind, though - I see your title already is limited at mobile sizes.



Answered By - RichardB
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, October 8, 2022

[FIXED] How to get the means and standard deviations of two overlapping normal distributions?

 October 08, 2022     data-analysis, mean, overlapping, statistics, stdev     No comments   

Issue

I have the following plot:

Overlapping normal distributions

I would like to estimate the means and standard deviations of the apparent overlapping normal distributions. This is slightly complicated by the fact that since the data is based on hour of the day, it also is circular -- the right end of the tail(s) leak into the left end.

How do I handle this?


Solution

I'd like to thank Robert Dodier and Adrian Keister for the start and the GitHub project provided by Emily Grace Ripka: Peak fitting Jupyter notebook

I was able to approximate the two different overlapped distributions with von Mises distributions and then optimized the predictions to minimize the error by selecting the mean and kappa (equivalent to the standard deviation of a von Mises distribution).

I was able to accomplish this with the SciPy Python module classes: scipy.stats.vonmises and scipy.optimize.curve_fit

I created the following two helper functions:

def two_von_mises(x, amp1, cen1, kappa1, amp2, cen2, kappa2):
    return (amp1 * vonmises.pdf(x-cen1, kappa1)) + \
           (amp2 * vonmises.pdf(x-cen2, kappa2))

def one_von_mises(x, amp, cen, kappa):
    return amp * vonmises.pdf(x-cen, kappa)

I needed to convert the time of day to an interval range from -pi <= {time of day} < pi, like so:

hourly_df['Angle'] = ((two_pi * hourly_df['HourOfDay']) / 24) - np.pi

I was then able to use the curve_fit function of the scipy.optimize module like so:

popt, pcov = curve_fit(two_von_mises, hourly_df['Angle'], hourly_df['Count'], p0 = [1, 11, 1, 1, 18, 1])

From this I got all the estimates of the parameters for the two distributions (from the popt variable above):

array([1.66877995e+04, 2.03310292e+01, 2.03941267e+00, 3.61717300e+04,
       2.46426705e+01, 1.32666704e+00])

Plotting this we see: Data with superimposed von Mises pdf graphed The next steps will be to see if we can determine what distribution a query belongs to based on categorical data collected for each query, but that is another story...

Thanks!



Answered By - Mark Solinski
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing